Class CriteriaUtility

java.lang.Object
org.refcodes.criteria.CriteriaUtility

public final class CriteriaUtility extends Object
The Class CriteriaUtility.
  • Method Details

    • getPartitions

      public static <P> Set<P> getPartitions(Criteria aCriteria, String aKey, Class<P> aType) throws CriteriaException.BadCriteriaException
      Tries to determine the partitions specified by the given key and type being addressed by the query represented by the given criteria. Actually EqualWithCriteria values for the partition key and type (compared to the partition value) are determined embedded in CriteriaNodes. ------------------------------------------------------------------------- Caution: In order for partitioning to work, the provided key specifying the partition must be reflected in the criteria's key. The following rules are required in order to determine the partition from the criteria: The provided criteria must be of type CriteriaNode or EqualWithCriteria. The CriteriaNode must contain one ore more EqualWithCriteria referring the provided key and partition. -------------------------------------------------------------------------
      Type Parameters:
      P - the generic type
      Parameters:
      aCriteria - The criteria from which to retrieve the according partition.
      aKey - The key representing the partition criteria's key.
      aType - The type representing the partition criteria's value's type.
      Returns:
      A set with the values for the given key and type addressing partition(s) to which the Criteria are targeted at.
      Throws:
      CriteriaException.BadCriteriaException - thrown in case of problems related to some Criteria.
    • doRemovePartitionCriteria

      public static <C> Criteria doRemovePartitionCriteria(Criteria aCriteria, String aKey, Set<C> aPartitions)
      Removes the criteria for the provided partitions given key. Make sure that the criteria does not address more than one(!) partition in case you use this method with a e.g. PartedLoggerImpl. Only in case one partition is addressed by the criteria, then the partition to be addressed is known and then we can safely remove the criteria. Use the getPartitions(Criteria, String, Class) method for getting the partitions being addressed by the given criteria. When there is just one partition being addressed, then this partition's criteria may be removed from the criteria: The criteria's query is targeted at the according partition, we do not need to include the select statement for that partition! Actually EqualWithCriteria for the partition columns and the given partition are removed. ------------------------------------------------------------------------- Caution: In order for partitioning to work, the provided key specifying the partition must be reflected in the criteria's key. The following rules are required in order to determine the partition from the criteria: The provided criteria must be of type CriteriaNode or EqualWithCriteria. The CriteriaNode must contain one ore more EqualWithCriteria referring the provided key and partition. -------------------------------------------------------------------------
      Type Parameters:
      C - the generic type
      Parameters:
      aCriteria - The criteria from which to retrieve the according partition
      aKey - The key representing the partition criteria's key.
      aPartitions - The partitions for which to remove the criteria
      Returns:
      The criteria without the criteria referring to the provided key and the provided partitions