Class AttributeRangeMap

java.lang.Object
com.mayam.wf.attributes.shared.AttributeRangeMap
All Implemented Interfaces:
Copyable, Serializable

public class AttributeRangeMap extends Object implements Serializable, Copyable
Map from Attribute to a pair of values representing the start and the end of a range. Optionally, each attribute range may be specified to include null values. When properly injected, the map will validate input to make sure it conforms to Attribute annotations.
Author:
Markus MÃ¥rtensson
See Also:
  • Field Details

  • Constructor Details

    • AttributeRangeMap

      public AttributeRangeMap()
  • Method Details

    • injectHelpers

      @Inject public void injectHelpers(AttributeValidator validator, AttributeFieldMapper attributeFieldMapper)
      Injects helper objects. Generally called by injector during creation, later using Injector.injectMembers() or manually by an object having access to both instances. A missing validator will cause the map to silently accept all input whereas
      Parameters:
      validator - AttributeValidator instance.
    • hasInjectedHelpers

      public boolean hasInjectedHelpers()
      Checks for the existence of AttributeValidator helper instance.
      Returns:
      true if the helper is injected.
    • hashCode

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • setAttributeRange

      public AttributeRangeMap setAttributeRange(Attribute attribute, Object start, Object end)
      Sets the range for a given Attribute. Null values are not considered part of the range. Requires a AttributeFieldMapper implementation, which is typically only bound on the server side.
      Parameters:
      attribute - the attribute to set.
      start - the start of the range.
      end - the end of the range.
      Returns:
      the map to allow method chaining.
    • setAttributeRange

      public AttributeRangeMap setAttributeRange(Attribute attribute, Object start, Object end, boolean includeNulls)
      Sets the range for a given Attribute.
      Parameters:
      attribute - the attribute to set.
      start - the start of the range.
      end - the end of the range.
      includeNulls - if true, nulls are considered part of the range.
      Returns:
      the map to allow method chaining.
    • setAttributeRangeByFieldId

      public AttributeRangeMap setAttributeRangeByFieldId(String fieldId, Object start, Object end)
      Sets the range for a given a field identifier. Null values are not considered part of the range. Requires a AttributeFieldMapper implementation, which is typically only bound on the server side.
      Parameters:
      fieldId - the field identifier.
      start - the start of the range.
      end - the end of the range.
      Returns:
      the map to allow method chaining.
    • setAttributeRangeByFieldId

      public AttributeRangeMap setAttributeRangeByFieldId(String fieldId, Object start, Object end, boolean includeNulls)
      Sets the range for a given a field identifier. Null values are not considered part of the range. Requires a AttributeFieldMapper implementation, which is typically only bound on the server side.
      Parameters:
      fieldId - the field identifier.
      start - the start of the range.
      end - the end of the range.
      includeNulls - if true, nulls are considered part of the range.
      Returns:
      the map to allow method chaining.
    • getAttributeRange

      public AttributeRangeMap.Range getAttributeRange(Attribute attribute)
      Gets the range for a given Attribute.
      Parameters:
      attribute - the attribute to get.
      Returns:
      the range as a tuple of start and end value.
    • getAttributeRangebyFieldId

      public AttributeRangeMap.Range getAttributeRangebyFieldId(String fieldId)
      Gets the range for a given field identifier. Requires a AttributeFieldMapper implementation, which is typically only bound on the server side.
      Parameters:
      fieldId - the field identifier.
      Returns:
      the range as a tuple of start and end value.
    • putAll

      public void putAll(AttributeRangeMap other)
    • remove

      public void remove(Attribute attribute)
    • clear

      public void clear()
      Removes all values from the map.
    • containsAttribute

      public boolean containsAttribute(Attribute attribute)
    • getAttributeSet

      public Set<Attribute> getAttributeSet()
    • copy

      public AttributeRangeMap copy()
      Creates a full copy of the map.
      Specified by:
      copy in interface Copyable
      Returns:
      new map.
    • copy

      public AttributeRangeMap copy(Collection<Attribute> attributes)
      Creates a partial copy of the map, including only the provided collection of attributes.
      Returns:
      new map.
    • getStartManager

      public AttributeManager getStartManager()
      Returns an AttributeManager which manages only the start values of this map.
    • getEndManager

      public AttributeManager getEndManager()
      Returns an AttributeManager which manages only the end values of this map.
    • merge

      public static AttributeRangeMap merge(AttributeRangeMap original, AttributeRangeMap overrides)
      Merges two AttributeRangeMap objects with priority given to the one referred to as "overrides". Expected to be called as "original = merge(original,overrides)". For this reason, original may become updated whereas overrides will not be touched.
      Parameters:
      original - original map, or null.
      overrides - map with overrides, or null.
      Returns:
      merged map, or null if both arguments were null.