Class EntityFieldMap

java.lang.Object
org.apache.ofbiz.entity.condition.EntityFieldMap
All Implemented Interfaces:
Serializable, IsEmpty, EntityCondition

public final class EntityFieldMap extends Object
A condition expression corresponding to an unordered collection of conditions containing two values compared with a comparison operator and that are joined by an operator.

The main objective it to express the conjunction or disjunction of a set of conditions which in the case of conjunction corresponds to SQL expression of the form foo=bar AND bar=baz AND ... and where the comparison operator is = and the join operator is AND.

See Also:
  • Constructor Details

    • EntityFieldMap

      @SafeVarargs public EntityFieldMap(EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp, V... keysValues)
      Constructs a map of fields.
      Type Parameters:
      V - The type of values that are compared.
      Parameters:
      compOp - the operator used to compare fields
      joinOp - the operator used to join field comparisons
      keysValues - a list of values that the field map will contain. This list must be of even length and each successive pair will be associated in the field map.
    • EntityFieldMap

      public EntityFieldMap(Map<String,V> fieldMap, EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp)
      Constructs a map of fields.
      Type Parameters:
      V - the type of values contained in fieldMap
      Parameters:
      fieldMap - the map containing the fields to compare
      compOp - the operator to compare fields
      joinOp - the operator to join entries in the field map
  • Method Details

    • getField

      public Object getField(String name)
      Gets the value associated with field name.
      Parameters:
      name - the name of the field
      Returns:
      the value associated with field name
      Throws:
      NullPointerException - if the specified name is null and the field map does not permit null keys
    • containsField

      public boolean containsField(String name)
      Checks if the field map contains the field name.
      Parameters:
      name - the name of the field to search
      Returns:
      true if field is defined in the field map
      Throws:
      NullPointerException - if the specified name is null and the field map does not permit null keys
    • getFieldKeyIterator

      public Iterator<String> getFieldKeyIterator()
      Provides an iterator on the fields contained in the field map.
      Returns:
      an iterator of fields
    • getFieldEntryIterator

      public Iterator<Map.Entry<String,? extends Object>> getFieldEntryIterator()
      Provides an iterator on the entries contained in the field map.
      Returns:
      an iterator of field entries
    • accept

      public void accept(EntityConditionVisitor visitor)
      Description copied from interface: EntityCondition
      Applies a visitor to this condition.
      Parameters:
      visitor - the visitor to be applied
    • getConditions

      public List<? extends EntityExpr> getConditions()
    • getOperator

      public EntityJoinOperator getOperator()
      Gets the infix operator used to combine every elements in the list of conditions.
      Returns:
      the infix operator used to combine every elements in the list of conditions.
    • getCondition

      public EntityExpr getCondition(int index)
      Gets the condition expression stored at a particular of the internal list of conditions.
      Parameters:
      index - the index of the condition expression to find
      Returns:
      the corresponding condition expression
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface IsEmpty
    • makeWhereString

      public String makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, Datasource datasourceInfo)
      Description copied from interface: EntityCondition
      Dumps the corresponding SQL string.
      Specified by:
      makeWhereString in interface EntityCondition
      Parameters:
      modelEntity - the model of the entity
      entityConditionParams - the effective parameters used to substitute '?' parameters
      datasourceInfo - the model of the data source interpreting the SQL
      Returns:
      the corresponding SQL string
    • checkCondition

      public void checkCondition(ModelEntity modelEntity) throws GenericModelException
      Description copied from interface: EntityCondition
      Verifies that this condition expression is valid.
      Specified by:
      checkCondition in interface EntityCondition
      Parameters:
      modelEntity - the model of the entity
      Throws:
      GenericModelException - when this condition expression is not valid
    • mapMatches

      public boolean mapMatches(Delegator delegator, Map<String,? extends Object> map)
      Description copied from interface: EntityCondition
      Checks that this condition expression matches a particular entity.
      Specified by:
      mapMatches in interface EntityCondition
      Parameters:
      delegator - the delegator used to match
      map - the entity definition to match
      Returns:
      true if this condition expression matches map when using delegator
    • freeze

      public EntityCondition freeze()
      Description copied from interface: EntityCondition
      Create a Frozen condition expression corresponding to this condition expression.
      Specified by:
      freeze in interface EntityCondition
      Returns:
      the frozen condition expression
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object