Topics on this page:

Next section

Transformation Filters

Some standard transformations support transformation filters. Transformation filters are classes that will screen input records processed. All filters must implement interface Filter (see Function).

Comparison Operators

Transform4J provides filter FilterCondition out of the box. FilterCondition provides the following comparison operators:

  • EQUALS
  • GREATER_THAN
  • GREATER_OR_EQUAL
  • LESS_THAN
  • LESS_OR_EQUAL
  • CONTAINS -- Record value contains the value of this operator. Implemented by String.contains().
  • Note that values are "normalized" before being compared (see ValueNormalizationUtils). This prevents silliness like Integer 1 not equalling Long 1 or something like that.

    Examples of single condition filters follow:

    Filter<DataRecord> filter = new FilterCondition("age", FilterCondition.Operator.GREATER_THAN, 14);
    			 
    Filter<DataRecord> filter = new FilterCondition("lastName", FilterCondition.Operator.EQUALS, "Ashmore");
    			 
    Filter<DataRecord> filter = new FilterCondition("lastName", FilterCondition.Operator.EQUALS, "Ashmore");
    			 

    Logical Operators

    Additionally, compound conditions are supported by the following logical operators:

  • Not
  • And
  • Or
  • Examples of compound condition usage follow:

    Filter<DataRecord> filter = new FilterCondition("age", FilterCondition.Operator.GREATER_THAN, 14)
    	.and(new FilterCondition("middleInitial", FilterCondition.Operator.EQUALS, "C"));
    			 
    Filter<DataRecord> filter = new FilterCondition("lastName", FilterCondition.Operator.EQUALS, "Ashmore").not();
    			 
    Filter<DataRecord> filter = new FilterCondition("age", FilterCondition.Operator.GREATER_THAN, 14)
    	.or(new FilterCondition("middleInitial", FilterCondition.Operator.EQUALS, "C"));
    			 

    See FilterCondition for more information.