Class MappingProcessingRule<T>
- java.lang.Object
-
- org.incenp.obofoundry.sssom.transform.MappingProcessingRule<T>
-
- Type Parameters:
T- The type of object that should be produced by the generator from a mapping.
public class MappingProcessingRule<T> extends Object
This class represents an arbitrary treatment applied to a mapping.A processing rule is made of:
- a filter, to decide whether the rule should be applied to a given mapping;
- a preprocessor, to modify the mapping the rule is applied to;
- a generator, to produce an object from the mapping.
-
-
Constructor Summary
Constructors Constructor Description MappingProcessingRule(IMappingFilter filter, IMappingTransformer<Mapping> preprocessor, IMappingTransformer<T> generator)Creates a new instance.MappingProcessingRule(IMappingFilter filter, IMappingTransformer<Mapping> preprocessor, IMappingTransformer<T> generator, IMappingProcessorCallback callback)Creates a new instance that includes a custom processing step.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapply(Mapping mapping)Checks whether the rule should be applied to the given mapping.booleancall(List<Mapping> mappings)Calls the custom callback associated with the rule, if any.booleandoesInferCardinality()Indicates whether this rule takes care of computing cardinality information.Tgenerate(Mapping mapping)Generates the output object from the given mapping.Set<String>getTags()Gets the tags associated with the rule.booleanneedsCardinality()Indicates whether this rule makes use of cardinality information.Mappingpreprocess(Mapping mapping)Applies the preprocessing step to the given mapping.StringtoString()
-
-
-
Constructor Detail
-
MappingProcessingRule
public MappingProcessingRule(IMappingFilter filter, IMappingTransformer<Mapping> preprocessor, IMappingTransformer<T> generator)
Creates a new instance.- Parameters:
filter- The filter to select the mappings this rule will be applied to; if the filter returnstruefor a given mapping, the rule is applied. Ifnull, the rule is applied to any mapping.preprocessor- The preprocessor to modify the mapping; it takes a mapping and returns another mapping; ifnull, the mapping is unmodified.generator- The generator to produce the desired object from the mapping; ifnull, the rule will producenull.
-
MappingProcessingRule
public MappingProcessingRule(IMappingFilter filter, IMappingTransformer<Mapping> preprocessor, IMappingTransformer<T> generator, IMappingProcessorCallback callback)
Creates a new instance that includes a custom processing step.- Parameters:
filter- The filter to select the mappings this rule will be applied to; if the filter returnstruefor a given mapping, the rule is applied. Ifnull, the rule is applied to any mapping.preprocessor- The preprocessor to modify the mapping; it takes a mapping and returns another mapping; ifnull, the mapping is unmodified.generator- The generator to produce the desired object from the mapping; ifnull, the rule will producenull.callback- A callback method to call when this rule is being processed; if set, the callback will be called before the processor starts iterating over the mappings.
-
-
Method Detail
-
needsCardinality
public boolean needsCardinality()
Indicates whether this rule makes use of cardinality information.- Returns:
trueif the rule needs accurate cardinality information,falseotherwise.
-
doesInferCardinality
public boolean doesInferCardinality()
Indicates whether this rule takes care of computing cardinality information.- Returns:
trueif the rule infer cardinality values,falseotherwise.
-
getTags
public Set<String> getTags()
Gets the tags associated with the rule.- Returns:
- The set of tags for this rule.
-
apply
public boolean apply(Mapping mapping)
Checks whether the rule should be applied to the given mapping.- Parameters:
mapping- The mapping to check.- Returns:
trueif the rule applies to the mapping, otherwisefalse; if no filter has been set, alwaystrue.
-
preprocess
public Mapping preprocess(Mapping mapping)
Applies the preprocessing step to the given mapping.- Parameters:
mapping- The mapping to preprocess.- Returns:
- The preprocessed mapping; if no preprocessor has been set, the original, unmodified mapping.
-
generate
public T generate(Mapping mapping)
Generates the output object from the given mapping.- Parameters:
mapping- The mapping to generate an object from.- Returns:
- The object derived from the mapping by application of the rule;
always
nullif no generator has been set.
-
call
public boolean call(List<Mapping> mappings)
Calls the custom callback associated with the rule, if any.- Parameters:
mappings- The current set of mappings.- Returns:
trueif the processor should still proceed with that rule (i.e. iterate over the mappings and apply the preprocessor and generator as needed), orfalseif it should proceed to the next rule instead.
-
-