public abstract class AbstractParameterInfo extends Object implements ParameterInfo
Modifier and Type | Field and Description |
---|---|
protected static Object |
NO_MERGE
is used as return value when value cannot be added
|
UNLIMITED_OCCURRENCES
Modifier | Constructor and Description |
---|---|
protected |
AbstractParameterInfo(ParameterInfo containerItemAccessor) |
Modifier and Type | Method and Description |
---|---|
ImmutableMap |
addValueAs(ImmutableMap parameters,
Object value)
Matches `value` into `parameters` under the name/structure defined by this ParameterInfo.
|
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
|
protected Object |
addValueToContainer(Object container,
Function<Object,Object> merger) |
protected <T> T |
castTo(Object o,
Class<T> type) |
protected <T> T |
convertSingleValue(Factory factory,
Object value,
Class<T> type) |
protected <T> void |
convertValue(Factory factory,
ResultHolder<T> result,
Object rawValue) |
ContainerKind |
getContainerKind() |
protected ContainerKind |
getContainerKind(ImmutableMap params) |
protected ContainerKind |
getContainerKind(Object existingValue,
Object value) |
protected AbstractParameterInfo |
getContainerKindAccessor(ContainerKind containerKind) |
protected String |
getContainerName() |
protected abstract <T> T |
getEmptyContainer() |
Quantifier |
getMatchingStrategy() |
int |
getMaxOccurrences() |
int |
getMinOccurrences() |
String |
getName() |
Class<?> |
getParameterValueType() |
protected abstract String |
getPlainName() |
protected Object |
getValue(ImmutableMap parameters) |
<T> void |
getValueAs(Factory factory,
ResultHolder<T> result,
ImmutableMap parameters)
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) |
ValueConvertor |
getValueConvertor() |
protected abstract String |
getWrappedName(String containerName) |
boolean |
isMandatory(ImmutableMap parameters) |
boolean |
isMultiple() |
boolean |
isRepeatable() |
boolean |
isTryNextMatch(ImmutableMap parameters) |
protected boolean |
matches(Object value)
Checks whether `value` matches with required type and match condition.
|
protected Object |
merge(Object existingValue,
Object newValue) |
protected Object |
mergeSingle(Object existingValue,
Object newValue) |
AbstractParameterInfo |
setContainerKind(ContainerKind containerKind) |
<T> AbstractParameterInfo |
setMatchCondition(Class<T> requiredType,
Predicate<T> matchCondition) |
void |
setMatchingStrategy(Quantifier matchingStrategy) |
void |
setMaxOccurrences(int maxOccurrences) |
AbstractParameterInfo |
setMinOccurrences(int minOccurrences) |
AbstractParameterInfo |
setParameterValueType(Class<?> parameterValueType) |
AbstractParameterInfo |
setRepeatable(boolean repeatable) |
AbstractParameterInfo |
setValueConvertor(ValueConvertor valueConvertor) |
String |
toString() |
protected static final Object NO_MERGE
protected AbstractParameterInfo(ParameterInfo containerItemAccessor)
protected String getContainerName()
public final String getName()
getName
in interface ParameterInfo
ParameterInfo
protected abstract String getPlainName()
public ImmutableMap addValueAs(ImmutableMap parameters, Object value)
ParameterInfo
ParameterInfo
2) creates new copy of ImmutableMap
which contains the new `value` and returns that copyaddValueAs
in interface ParameterInfo
parameters
- the existing parametersvalue
- the new, to be stored valueprotected Object addValueToContainer(Object container, Function<Object,Object> merger)
protected AbstractParameterInfo getContainerKindAccessor(ContainerKind containerKind)
protected abstract Object addValueAs(Object container, Function<Object,Object> merger)
container
- a container of valuesmerger
- a code which merges existing value from container with new value and returns merged value, which has to be stored in the container insteadprotected abstract <T> T getEmptyContainer()
public <T> AbstractParameterInfo setMatchCondition(Class<T> requiredType, Predicate<T> matchCondition)
requiredType
- a required type of the value which matches as value of this parametermatchCondition
- a Predicate
which selects matching valuesprotected boolean matches(Object value)
value
- public Class<?> getParameterValueType()
getParameterValueType
in interface ParameterInfo
public AbstractParameterInfo setParameterValueType(Class<?> parameterValueType)
parameterValueType
- a type of the value which is acceptable by this parameterpublic boolean isMultiple()
isMultiple
in interface ParameterInfo
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.public int getMinOccurrences()
public AbstractParameterInfo setMinOccurrences(int minOccurrences)
public int getMaxOccurrences()
isMultiple()
==false, then it never returns value > 1public void setMaxOccurrences(int maxOccurrences)
public Quantifier getMatchingStrategy()
getMatchingStrategy
in interface ParameterInfo
RootNode
spublic void setMatchingStrategy(Quantifier matchingStrategy)
public ValueConvertor getValueConvertor()
ValueConvertor
used by reading and writing into parameter values defined by this ParameterInfo
public AbstractParameterInfo setValueConvertor(ValueConvertor valueConvertor)
valueConvertor
- the ValueConvertor
used by reading and writing into parameter values defined by this ParameterInfo
public boolean isRepeatable()
isRepeatable
in interface ParameterInfo
public boolean isMandatory(ImmutableMap parameters)
isMandatory
in interface ParameterInfo
parameters
- matching parameterspublic boolean isTryNextMatch(ImmutableMap parameters)
isTryNextMatch
in interface ParameterInfo
parameters
- matching parameterspublic ContainerKind getContainerKind()
public AbstractParameterInfo setContainerKind(ContainerKind containerKind)
protected ContainerKind getContainerKind(ImmutableMap params)
protected ContainerKind getContainerKind(Object existingValue, Object value)
public <T> void getValueAs(Factory factory, ResultHolder<T> result, ImmutableMap parameters)
ParameterInfo
ParameterInfo
from the `parameters`
and adds that 0, 1 or more values into result (depending on type of result)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 valueparameters
- here are stored all the parameter valuesprotected Object getValue(ImmutableMap parameters)
protected <T> void convertValue(Factory factory, ResultHolder<T> result, Object rawValue)
Copyright © 2007–2019 Inria. All rights reserved.