Class AbstractParameterInfo

All Implemented Interfaces:
Direct Known Subclasses:
ComputedParameterInfo, ListParameterInfo, MapParameterInfo, SetParameterInfo

public abstract class AbstractParameterInfo extends Object implements ParameterInfo
  • Field Details

    • NO_MERGE

      protected static final Object NO_MERGE
      is used as return value when value cannot be added
  • Constructor Details

    • AbstractParameterInfo

      protected AbstractParameterInfo(ParameterInfo containerItemAccessor)
  • Method Details

    • getContainerName

      protected String getContainerName()
    • getName

      public final String getName()
      Specified by:
      getName in interface ParameterInfo
      the full name of the parameter from the root of parameter container to the value represented by this ParameterInfo
    • getPlainName

      protected abstract String getPlainName()
    • getWrappedName

      protected abstract String getWrappedName(String containerName)
    • addValueAs

      public ImmutableMap addValueAs(ImmutableMap parameters, Object value)
      Description copied from interface: ParameterInfo
      Matches `value` into `parameters` under the name/structure defined by this ParameterInfo. 1) checks that value matches with optional internal rules of this ParameterInfo 2) creates new copy of ImmutableMap which contains the new `value` and returns that copy
      Specified by:
      addValueAs in interface ParameterInfo
      parameters - the existing parameters
      value - the new, to be stored value
      copy of `parameters` with new value or existing `parameters` if value is already there or null if value doesn't fit into these parameters
    • addValueToContainer

      protected Object addValueToContainer(Object container, Function<Object,​Object> merger)
    • merge

      protected Object merge(Object existingValue, Object newValue)
    • getContainerKindAccessor

      protected AbstractParameterInfo getContainerKindAccessor(ContainerKind containerKind)
    • mergeSingle

      protected Object mergeSingle(Object existingValue, Object newValue)
    • addValueAs

      protected abstract Object addValueAs(Object container, Function<Object,​Object> merger)
      takes existing item value from the `container`, sends it as parameter into `merger` and get's new to be stored value stores that value into new `container` and returns it
      container - a container of values
      merger - a code which merges existing value from container with new value and returns merged value, which has to be stored in the container instead
      copy of the container with merged value
    • castTo

      protected <T> T castTo(Object o, Class<T> type)
    • getEmptyContainer

      protected abstract <T> T getEmptyContainer()
    • setMatchCondition

      public <T> AbstractParameterInfo setMatchCondition(Class<T> requiredType, Predicate<T> matchCondition)
      requiredType - a required type of the value which matches as value of this parameter
      matchCondition - a Predicate which selects matching values
    • matches

      protected boolean matches(Object value)
      Checks whether `value` matches with required type and match condition.
      value -
    • getParameterValueType

      public Class<?> getParameterValueType()
      Specified by:
      getParameterValueType in interface ParameterInfo
      a type of parameter value - if known Note: Pattern builder needs to know the value type to be able to select substitute node. For example patter: return _expression_.S(); either replaces only `_expression_.S()` if the parameter value is an expression or replaces `return _expression_.S()` if the parameter value is a CtBlock
    • setParameterValueType

      public AbstractParameterInfo setParameterValueType(Class<?> parameterValueType)
      parameterValueType - a type of the value which is acceptable by this parameter
      this to support fluent API
    • isMultiple

      public boolean isMultiple()
      Specified by:
      isMultiple in interface ParameterInfo
      true if the value container has to be a List, otherwise the container will be a single value
    • setRepeatable

      public AbstractParameterInfo setRepeatable(boolean repeatable)
      repeatable - if this matcher can be applied more than once in the same container of targets Note: even if false, it may be applied again to another container and to match EQUAL value.
      this to support fluent API
    • getMinOccurrences

      public int getMinOccurrences()
    • setMinOccurrences

      public AbstractParameterInfo setMinOccurrences(int minOccurrences)
    • getMaxOccurrences

      public int getMaxOccurrences()
      maximum number of values in this parameter. Note: if isMultiple()==false, then it never returns value > 1
    • setMaxOccurrences

      public void setMaxOccurrences(int maxOccurrences)
    • getMatchingStrategy

      public Quantifier getMatchingStrategy()
      Specified by:
      getMatchingStrategy in interface ParameterInfo
      the strategy used to resolve conflict between two RootNodes
    • setMatchingStrategy

      public void setMatchingStrategy(Quantifier matchingStrategy)
    • getValueConvertor

      public ValueConvertor getValueConvertor()
      the ValueConvertor used by reading and writing into parameter values defined by this ParameterInfo
    • setValueConvertor

      public AbstractParameterInfo setValueConvertor(ValueConvertor valueConvertor)
      valueConvertor - the ValueConvertor used by reading and writing into parameter values defined by this ParameterInfo
    • isRepeatable

      public boolean isRepeatable()
      Specified by:
      isRepeatable in interface ParameterInfo
      true if this matcher can be applied more than once in the same container of targets Note: even if false, it may be applied again to another container and to match EQUAL value
    • isMandatory

      public boolean isMandatory(ImmutableMap parameters)
      Specified by:
      isMandatory in interface ParameterInfo
      parameters - matching parameters
      true if the ValueResolver of this parameter MUST match with next target in the state defined by current `parameters`. false if match is optional
    • isTryNextMatch

      public boolean isTryNextMatch(ImmutableMap parameters)
      Specified by:
      isTryNextMatch in interface ParameterInfo
      parameters - matching parameters
      true if the ValueResolver of this parameter should be processed again to match next target in the state defined by current `parameters`.
    • getContainerKind

      public ContainerKind getContainerKind()
    • setContainerKind

      public AbstractParameterInfo setContainerKind(ContainerKind containerKind)
    • getContainerKind

      protected ContainerKind getContainerKind(ImmutableMap params)
    • getContainerKind

      protected ContainerKind getContainerKind(Object existingValue, Object value)
    • getValueAs

      public <T> void getValueAs(Factory factory, ResultHolder<T> result, ImmutableMap parameters)
      Description copied from interface: ParameterInfo
      Takes the value of parameter identified by this ParameterInfo from the `parameters` and adds that 0, 1 or more values into result (depending on type of result)
      Specified by:
      getValueAs in interface ParameterInfo
      factory - the factory used to create new entities if conversion of value is needed before it can be added into `result`
      result - the receiver of the result value. It defined required type of returned value and multiplicity of returned value
      parameters - here are stored all the parameter values
    • getValue

      protected Object getValue(ImmutableMap parameters)
    • convertValue

      protected <T> void convertValue(Factory factory, ResultHolder<T> result, Object rawValue)
    • convertSingleValue

      protected <T> T convertSingleValue(Factory factory, Object value, Class<T> type)
    • toString

      public String toString()
      toString in class Object