All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.uscexp.blockformatpropertyfile.PropertyCriteriaSequence Maven / Gradle / Ivy

There is a newer version: 0.2.0-Beta
Show newest version
/*
 * Copyright (C) 2014 by haui - all rights reserved
 */
package com.github.uscexp.blockformatpropertyfile;

/**
 * @author haui
 *
 */
public class PropertyCriteriaSequence implements PropertyCriteria {

	// member variables
	private PropertyCriteria pc1;
	private PropertyCriteria pc2;
	private SequenceCondition logicalOperator;

	/**
	 * constructor for a PropertyCriteriaSequence
	 *
	 * @param pc1
	 *            first PropertyCriteria
	 * @param pc2
	 *            second PropertyCriteria
	 * @param logicalOperator
	 *            logical operator
	 */
	public PropertyCriteriaSequence(PropertyCriteria pc1, PropertyCriteria pc2, SequenceCondition logicalOperator) {
		this.pc1 = pc1;
		this.pc2 = pc2;
		this.logicalOperator = logicalOperator;
	}

	@Override
	public void extractValueToBeChecked(PropertyStruct ps) {
		pc1.extractValueToBeChecked(ps);
		pc2.extractValueToBeChecked(ps);
	}

	//@formatter:off
	  /**
	   * compares the two given values
	   * 
* EQUAL -{@literal >} internal valueToBeChecked = internal value *
* NOT_EQUAL -{@literal >} internal valueToBeChecked != internal value *
* EQUAL_NOCASE -{@literal >} internal valueToBeChecked = value (only Strings, not case sensitive) *
* NOT_EQUAL_NOCASE -{@literal >} internal valueToBeChecked != value (only Strings, not case sensitive) *
* GREATER -{@literal >} internal valueToBeChecked {@literal >} internal value *
* GREATER_EQUAL -{@literal >} internal valueToBeChecked {@literal >}= internal value *
* SMALLER -{@literal >} internal valueToBeChecked {@literal <} internal value *
* SMALLER_EQUAL -{@literal >} internal valueToBeChecked {@literal <}= internal value *
* CONTAINS -{@literal >} internal valueToBeChecked included in value (only Strings, case sensitive) *
* CONTAINS_NOCASE -{@literal >} internal valueToBeChecked included in value (only Strings, not case sensitive) * * @return true if contition is true */ @Override public boolean compare() { //@formatter:on boolean blRet = false; switch (logicalOperator) { case AND: blRet = pc1.compare() && pc2.compare(); break; case OR: blRet = pc1.compare() || pc2.compare(); break; } return blRet; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy