Class BetweenMatcher

java.lang.Object
org.smartparam.engine.matchers.BetweenMatcher
All Implemented Interfaces:
Matcher

public class BetweenMatcher extends Object implements Matcher

Range matcher, checks if value fits in range defined in pattern. Value type and pattern type must also match. It is possible to define range inclusiveness or exclusiveness, separately for each of range border value.

Between matcher has a set of default separators, that will be used to separate values for beginning and end of range. These separators are (order matters):
 : - ,
 
First separator that was found in pattern string is used to split it. Use setSeparators(java.lang.String) to override defaults.
Since:
0.9.0
Author:
Przemek Hertel
  • Constructor Details

    • BetweenMatcher

      public BetweenMatcher(String lowerInclusive, String upperInclusive)
    • BetweenMatcher

      public BetweenMatcher(String lowerInclusive, String upperInclusive, String separators)
    • BetweenMatcher

      public BetweenMatcher(boolean lowerInclusive, boolean upperInclusive, String separators)
      Parameters:
      lowerInclusive - range lower end should be inclusive?
      upperInclusive - range upper end should be inclusive?
      separators - separators to use
    • BetweenMatcher

      public BetweenMatcher(boolean lowerInclusive, boolean upperInclusive)
      Parameters:
      lowerInclusive - range lower end should be inclusive?
      upperInclusive - range upper end should be inclusive?
  • Method Details

    • matches

      public <T extends ValueHolder> boolean matches(String value, String pattern, Type<T> type)
      Description copied from interface: Matcher
      Check if value matches the pattern. Type can be used to parse value or to differentiate matchers behavior depending on value type. Type is defined per parameter Level.
      Specified by:
      matches in interface Matcher
      Type Parameters:
      T - level type
      Parameters:
      value - value form query (provided by user)
      pattern - pattern from parameter matrix (can be '*')
      type - type of value, might be null if none was set
      Returns:
      true if value matched, false otherwise
    • setLowerInclusive

      public final void setLowerInclusive(boolean lowerInclusive)
    • setUpperInclusive

      public final void setUpperInclusive(boolean upperInclusive)
    • setSeparators

      public final void setSeparators(String separators)
      Override default separators. Provided string is split into char array and each character is treated as a single separator.
      Parameters:
      separators - string value of separator