Class MoreRestrictions


  • public final class MoreRestrictions
    extends Object
    Utility functions to ease creation of restrictions. The package was chosen to be able to pass escape chars to the LikeExpression.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.hibernate.criterion.Criterion alwaysFalse()
      Creates a criterion that is always false.
      static org.hibernate.criterion.Criterion alwaysTrue()
      Creates a criterion that is always true.
      static Optional<? extends org.hibernate.criterion.Criterion> and​(Optional<? extends org.hibernate.criterion.Criterion>... criteria)  
      static boolean hasConditions​(org.hibernate.criterion.Junction j)  
      static org.hibernate.criterion.LikeExpression ilike​(String propertyName, String value, Character escapeChar)
      Create a new case-insensitive like expression.
      static org.hibernate.criterion.LikeExpression ilike​(String propertyName, String value, String escapeString)
      Create a new case-insensitive like expression.
      static org.hibernate.criterion.LikeExpression ilike​(String propertyName, String value, org.hibernate.criterion.MatchMode matchMode, Character escapeChar)
      Create a new case-insensitive like expression.
      static org.hibernate.criterion.LikeExpression ilike​(String propertyName, String value, org.hibernate.criterion.MatchMode matchMode, String escapeString)
      Create a new case-insensitive like expression.
      static org.hibernate.criterion.LikeExpression like​(String propertyName, String value)
      Create a new case-sensitive like expression.
      static org.hibernate.criterion.LikeExpression like​(String propertyName, String value, Character escapeChar, boolean ignoreCase)
      Create a new like expression.
      static org.hibernate.criterion.LikeExpression like​(String propertyName, String value, String escapeString, boolean ignoreCase)
      Create a new like expression.
      static org.hibernate.criterion.LikeExpression like​(String propertyName, String value, org.hibernate.criterion.MatchMode matchMode)
      Create a new case-sensitive like expression.
      static org.hibernate.criterion.LikeExpression like​(String propertyName, String value, org.hibernate.criterion.MatchMode matchMode, Character escapeChar, boolean ignoreCase)
      Create a new like expression.
      static org.hibernate.criterion.LikeExpression like​(String propertyName, String value, org.hibernate.criterion.MatchMode matchMode, String escapeString, boolean ignoreCase)
      Create a new like expression.
      static Optional<? extends org.hibernate.criterion.Criterion> or​(Optional<? extends org.hibernate.criterion.Criterion>... criteria)  
      static Collector<org.hibernate.criterion.Criterion,​?,​org.hibernate.criterion.Criterion> toConjunction()
      Create a Collector that collects criterions to a conjunction.
      static Collector<org.hibernate.criterion.Criterion,​?,​org.hibernate.criterion.Criterion> toDisjunction()
      Create a Collector that collects criterions to a disjunction.
    • Method Detail

      • ilike

        public static org.hibernate.criterion.LikeExpression ilike​(String propertyName,
                                                                   String value,
                                                                   Character escapeChar)
        Create a new case-insensitive like expression.
        Parameters:
        propertyName - the property name
        value - the value to compare against
        escapeChar - the escape char to use
        Returns:
        the expression
      • ilike

        public static org.hibernate.criterion.LikeExpression ilike​(String propertyName,
                                                                   String value,
                                                                   String escapeString)
        Create a new case-insensitive like expression.
        Parameters:
        propertyName - the property name
        value - the value to compare against
        escapeString - the escape string to use
        Returns:
        the expression
      • ilike

        public static org.hibernate.criterion.LikeExpression ilike​(String propertyName,
                                                                   String value,
                                                                   org.hibernate.criterion.MatchMode matchMode,
                                                                   Character escapeChar)
        Create a new case-insensitive like expression.
        Parameters:
        propertyName - the property name
        value - the value to compare against
        matchMode - the match mode
        escapeChar - the escape char to use
        Returns:
        the expression
      • ilike

        public static org.hibernate.criterion.LikeExpression ilike​(String propertyName,
                                                                   String value,
                                                                   org.hibernate.criterion.MatchMode matchMode,
                                                                   String escapeString)
        Create a new case-insensitive like expression.
        Parameters:
        propertyName - the property name
        value - the value to compare against
        matchMode - the match mode
        escapeString - the escape string to use
        Returns:
        the expression
      • like

        public static org.hibernate.criterion.LikeExpression like​(String propertyName,
                                                                  String value,
                                                                  Character escapeChar,
                                                                  boolean ignoreCase)
        Create a new like expression.
        Parameters:
        propertyName - the property name
        value - the value to compare against
        escapeChar - the escape char to use
        ignoreCase - if the match should be case-insensitive
        Returns:
        the expression
      • like

        public static org.hibernate.criterion.LikeExpression like​(String propertyName,
                                                                  String value,
                                                                  String escapeString,
                                                                  boolean ignoreCase)
        Create a new like expression.
        Parameters:
        propertyName - the property name
        value - the value to compare against
        escapeString - the escape string to use
        ignoreCase - if the match should be case-insensitive
        Returns:
        the expression
      • like

        public static org.hibernate.criterion.LikeExpression like​(String propertyName,
                                                                  String value)
        Create a new case-sensitive like expression.
        Parameters:
        propertyName - the property name
        value - the value to compare against
        Returns:
        the expression
      • like

        public static org.hibernate.criterion.LikeExpression like​(String propertyName,
                                                                  String value,
                                                                  org.hibernate.criterion.MatchMode matchMode)
        Create a new case-sensitive like expression.
        Parameters:
        propertyName - the property name
        value - the value to compare against
        matchMode - the match mode
        Returns:
        the expression
      • like

        public static org.hibernate.criterion.LikeExpression like​(String propertyName,
                                                                  String value,
                                                                  org.hibernate.criterion.MatchMode matchMode,
                                                                  String escapeString,
                                                                  boolean ignoreCase)
        Create a new like expression.
        Parameters:
        propertyName - the property name
        value - the value to compare against
        matchMode - the match mode
        escapeString - the escape string to use
        ignoreCase - if the match should be case-insensitive
        Returns:
        the expression
      • like

        public static org.hibernate.criterion.LikeExpression like​(String propertyName,
                                                                  String value,
                                                                  org.hibernate.criterion.MatchMode matchMode,
                                                                  Character escapeChar,
                                                                  boolean ignoreCase)
        Create a new like expression.
        Parameters:
        propertyName - the property name
        value - the value to compare against
        matchMode - the match mode
        escapeChar - the escape char to use
        ignoreCase - if the match should be case-insensitive
        Returns:
        the expression
      • alwaysFalse

        public static org.hibernate.criterion.Criterion alwaysFalse()
        Creates a criterion that is always false.
        Returns:
        the criterion
      • alwaysTrue

        public static org.hibernate.criterion.Criterion alwaysTrue()
        Creates a criterion that is always true.
        Returns:
        the criterion
      • toDisjunction

        public static Collector<org.hibernate.criterion.Criterion,​?,​org.hibernate.criterion.Criterion> toDisjunction()
        Create a Collector that collects criterions to a disjunction.
        Returns:
        the collector
      • toConjunction

        public static Collector<org.hibernate.criterion.Criterion,​?,​org.hibernate.criterion.Criterion> toConjunction()
        Create a Collector that collects criterions to a conjunction.
        Returns:
        the collector
      • and

        @SafeVarargs
        public static Optional<? extends org.hibernate.criterion.Criterion> and​(Optional<? extends org.hibernate.criterion.Criterion>... criteria)
      • or

        @SafeVarargs
        public static Optional<? extends org.hibernate.criterion.Criterion> or​(Optional<? extends org.hibernate.criterion.Criterion>... criteria)
      • hasConditions

        public static boolean hasConditions​(org.hibernate.criterion.Junction j)