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.
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
ConstructorsConstructorDescriptionMappingProcessingRule
(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
Modifier and TypeMethodDescriptionboolean
Checks whether the rule should be applied to the given mapping.boolean
Calls the custom callback associated with the rule, if any.boolean
Indicates whether this rule takes care of computing cardinality information.Generates the output object from the given mapping.getTags()
Gets the tags associated with the rule.boolean
Indicates whether this rule makes use of cardinality information.preprocess
(Mapping mapping) Applies the preprocessing step to the given mapping.toString()
-
Constructor Details
-
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 returnstrue
for 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 returnstrue
for 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 Details
-
needsCardinality
public boolean needsCardinality()Indicates whether this rule makes use of cardinality information.- Returns:
true
if the rule needs accurate cardinality information,false
otherwise.
-
doesInferCardinality
public boolean doesInferCardinality()Indicates whether this rule takes care of computing cardinality information.- Returns:
true
if the rule infer cardinality values,false
otherwise.
-
getTags
Gets the tags associated with the rule.- Returns:
- The set of tags for this rule.
-
apply
Checks whether the rule should be applied to the given mapping.- Parameters:
mapping
- The mapping to check.- Returns:
true
if the rule applies to the mapping, otherwisefalse
; if no filter has been set, alwaystrue
.
-
preprocess
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
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
null
if no generator has been set.
-
call
Calls the custom callback associated with the rule, if any.- Parameters:
mappings
- The current set of mappings.- Returns:
true
if the processor should still proceed with that rule (i.e. iterate over the mappings and apply the preprocessor and generator as needed), orfalse
if it should proceed to the next rule instead.
-
toString
-