Class SimpleType

java.lang.Object
nz.org.riskscape.engine.types.SimpleType
All Implemented Interfaces:
TypeIO, TypeIOConstructor, Type, TypeConstructor
Direct Known Subclasses:
Anything, Bool, Date, Decimal, Floating, Geom, GeomType, Integer, Nothing, Text

public abstract class SimpleType extends Object implements Type, TypeIO, TypeIOConstructor, TypeConstructor

Represents the simplest single-value type, e.g. integer, where any instance of the type is equal to any other instance

  • Field Details

  • Constructor Details

    • SimpleType

      public SimpleType()
  • Method Details

    • getInstance

      public static final <T extends SimpleType> T getInstance(Class<T> clazz)
      Returns:
      a singleton instance of a particular SimpleType. SimpleTypes only need one instance - this is their defining characteristic
    • getTypeInformation

      public static final TypeInformation getTypeInformation(Class<? extends SimpleType> clazz)
      Returns:
      the TypeInformation for a particular SimpleType class
    • isSimpleType

      public static boolean isSimpleType(Type typeToTest)
      Returns:
      true if typeToTest is a SimpleType, without any wrapping. A glorified instanceof, but wrapped in an API
    • equals

      public final boolean equals(Object rhs)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • asStruct

      public final Struct asStruct()
      Specified by:
      asStruct in interface Type
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • build

      public final TypeIO build(Type type, TypeIOBuilder builder)
      Specified by:
      build in interface TypeIOConstructor
    • writesType

      public final Type writesType()
      Specified by:
      writesType in interface TypeIO
      Returns:
      the exact type that this TypeIO can read/write
    • construct

      public Type construct(TypeBuilder typeBuilder, AST.Symbol symbol) throws TypeBuildingException
      Description copied from interface: TypeConstructor

      Attempt to build the type represented by this TypeConstructor

      Specified by:
      construct in interface TypeConstructor
      Parameters:
      typeBuilder - the type builder that is being used to build types. Contains helper methods for implementations.
      symbol - the ast that a type is being constructed from
      Returns:
      the fully constructed type
      Throws:
      TypeBuildingException - if something went wrong
    • getTypeInformationDescription

      protected String getTypeInformationDescription()
      Returns:
      a description string to use for this SimpleTypes TypeInformation object.
    • getTypeInformationId

      protected String getTypeInformationId()
      Returns:
      an identifier for this SimpleTypes TypeInformation object.
    • visit

      public <T, U> U visit(TypeVisitor<T,U> tv, T data)
      Description copied from interface: Type

      Type specific visiting logic. Types must decide whether they are atomic or compound and call the relevant method on TypeVisitor. It's up to each compound type to decide how they want to structure their children, e.g. order, metadata, and what's considered a child or not.

      Specified by:
      visit in interface Type