Package spoon.pattern.internal.parameter
Interface ParameterInfo
- All Known Implementing Classes:
AbstractParameterInfo
,ComputedParameterInfo
,ListParameterInfo
,MapParameterInfo
,SetParameterInfo
public interface ParameterInfo
Represents the parameter of
Pattern
defines acceptable value of parameter value during matching. For example type, filter on attribute values.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescription@Nullable ImmutableMap
addValueAs(ImmutableMap parameters, Object value)
Matches `value` into `parameters` under the name/structure defined by this ParameterInfo.getName()
Class<?>
<T> void
getValueAs(Factory factory, ResultHolder<T> result, ImmutableMap parameters)
Takes the value of parameter identified by thisParameterInfo
from the `parameters` and adds that 0, 1 or more values into result (depending on type of result)boolean
isMandatory(ImmutableMap parameters)
boolean
boolean
boolean
isTryNextMatch(ImmutableMap parameters)
-
Field Details
-
UNLIMITED_OCCURRENCES
static final int UNLIMITED_OCCURRENCES- See Also:
- Constant Field Values
-
-
Method Details
-
getName
String getName()- Returns:
- the full name of the parameter from the root of parameter container to the value represented by this
ParameterInfo
-
addValueAs
Matches `value` into `parameters` under the name/structure defined by this ParameterInfo. 1) checks that value matches with optional internal rules of thisParameterInfo
2) creates new copy ofImmutableMap
which contains the new `value` and returns that copy- Parameters:
parameters
- the existing parametersvalue
- the new, to be stored value- Returns:
- copy of `parameters` with new value or existing `parameters` if value is already there or null if value doesn't fit into these parameters
-
getValueAs
Takes the value of parameter identified by thisParameterInfo
from the `parameters` and adds that 0, 1 or more values into result (depending on type of result)- Parameters:
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 valueparameters
- here are stored all the parameter values
-
isMultiple
boolean isMultiple()- Returns:
- true if the value container has to be a List, otherwise the container will be a single value
-
getParameterValueType
Class<?> getParameterValueType()- Returns:
- 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
-
getMatchingStrategy
Quantifier getMatchingStrategy()- Returns:
- the strategy used to resolve conflict between two
RootNode
s
-
isRepeatable
boolean isRepeatable()- Returns:
- true if this matcher can be applied more then 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
- Parameters:
parameters
- matching parameters- Returns:
- 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
- Parameters:
parameters
- matching parameters- Returns:
- true if the ValueResolver of this parameter should be processed again to match next target in the state defined by current `parameters`.
-