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 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 returns true for a given mapping, the rule is applied. If null, the rule is applied to any mapping.
      preprocessor - The preprocessor to modify the mapping; it takes a mapping and returns another mapping; if null, the mapping is unmodified.
      generator - The generator to produce the desired object from the mapping; if null, the rule will produce null.
    • 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 returns true for a given mapping, the rule is applied. If null, the rule is applied to any mapping.
      preprocessor - The preprocessor to modify the mapping; it takes a mapping and returns another mapping; if null, the mapping is unmodified.
      generator - The generator to produce the desired object from the mapping; if null, the rule will produce null.
      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

      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:
      true if the rule applies to the mapping, otherwise false; if no filter has been set, always true.
    • 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 null if 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:
      true if the processor should still proceed with that rule (i.e. iterate over the mappings and apply the preprocessor and generator as needed), or false if it should proceed to the next rule instead.
    • toString

      public String toString()
      Overrides:
      toString in class Object