Class UnionProjector

java.lang.Object
nz.org.riskscape.engine.projection.UnionProjector
All Implemented Interfaces:
AutoCloseable, Function<nz.org.riskscape.engine.Tuple,nz.org.riskscape.engine.Tuple>, nz.org.riskscape.engine.pipeline.Realized, nz.org.riskscape.engine.projection.Projector

public class UnionProjector extends Object implements nz.org.riskscape.engine.projection.Projector

Takes tuples that potentially differ in type from two or more sources, and reprojects the tuples to a common type

TODO we can come back and rework this to use the ancestor type conversion

  • Constructor Summary

    Constructors
    Constructor
    Description
    UnionProjector(List<nz.org.riskscape.engine.types.Struct> sourceTypes, nz.org.riskscape.engine.types.Struct projectedType)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    nz.org.riskscape.engine.Tuple
    apply(nz.org.riskscape.engine.Tuple t)
     
    nz.org.riskscape.engine.types.Struct
     
    nz.org.riskscape.engine.types.Struct
     
    List<nz.org.riskscape.engine.types.Struct>
     
    static nz.org.riskscape.problem.ResultOrProblems<? extends nz.org.riskscape.engine.projection.Projector>
    realize(nz.org.riskscape.engine.typeset.TypeSet typeSet, List<nz.org.riskscape.engine.types.Struct> inputTypes)
     
    static nz.org.riskscape.problem.ResultOrProblems<? extends nz.org.riskscape.engine.projection.Projector>
    realize(nz.org.riskscape.engine.typeset.TypeSet typeSet, nz.org.riskscape.engine.types.Struct... inputTypes)
    Convenience API to build a UnionProjector from the given input types.
    static nz.org.riskscape.engine.types.Struct
    unionOf(nz.org.riskscape.engine.typeset.TypeSet typeSet, nz.org.riskscape.engine.types.Struct a, nz.org.riskscape.engine.types.Struct b)
    Takes the union of two structs.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Function

    andThen, compose

    Methods inherited from interface nz.org.riskscape.engine.projection.Projector

    getDirectMapping, getDirectMappingStrings, getSpatialMetadataMapper

    Methods inherited from interface nz.org.riskscape.engine.pipeline.Realized

    close
  • Constructor Details

    • UnionProjector

      public UnionProjector(List<nz.org.riskscape.engine.types.Struct> sourceTypes, nz.org.riskscape.engine.types.Struct projectedType)
  • Method Details

    • unionOf

      public static nz.org.riskscape.engine.types.Struct unionOf(nz.org.riskscape.engine.typeset.TypeSet typeSet, nz.org.riskscape.engine.types.Struct a, nz.org.riskscape.engine.types.Struct b)

      Takes the union of two structs. For shared attributes, the common ancestor type is used. Attributes that are only in one struct become nullable. Shared nested structs are recursed, so that they end up with a shared set of attributes (rather than becoming the Anything type.

      Returns:
      A Struct that is the union of the two structs' members
    • realize

      public static nz.org.riskscape.problem.ResultOrProblems<? extends nz.org.riskscape.engine.projection.Projector> realize(nz.org.riskscape.engine.typeset.TypeSet typeSet, List<nz.org.riskscape.engine.types.Struct> inputTypes)
      Returns:
      a new UnionProjector built from the given list of input types
    • realize

      public static nz.org.riskscape.problem.ResultOrProblems<? extends nz.org.riskscape.engine.projection.Projector> realize(nz.org.riskscape.engine.typeset.TypeSet typeSet, nz.org.riskscape.engine.types.Struct... inputTypes)

      Convenience API to build a UnionProjector from the given input types.

    • apply

      public nz.org.riskscape.engine.Tuple apply(nz.org.riskscape.engine.Tuple t)
      Specified by:
      apply in interface Function<nz.org.riskscape.engine.Tuple,nz.org.riskscape.engine.Tuple>
    • getSourceType

      public nz.org.riskscape.engine.types.Struct getSourceType()
      Specified by:
      getSourceType in interface nz.org.riskscape.engine.projection.Projector
    • getSourceTypes

      public List<nz.org.riskscape.engine.types.Struct> getSourceTypes()
    • getProjectedType

      public nz.org.riskscape.engine.types.Struct getProjectedType()
      Specified by:
      getProjectedType in interface nz.org.riskscape.engine.projection.Projector