Interface WrappingType

All Superinterfaces:
Type
All Known Implementing Classes:
CanonicalType, EmptyList, GeomType, GeomType.Line, GeomType.Point, GeomType.Polygon, IdentifiedType, LinkedType, MultiGeom, OfUnit, Referenced, WithinRange, WithinSet, WithMetadata

public interface WrappingType extends Type

Wrapping types add extra restrictions or metadata to a type that narrows that type. A wrapping type should not widen the type, e.g. make more values possible. A good example is something like WithinSet or an Enumeration, which wrap types to make only particular values of it valid.

  • Method Details

    • getUnderlyingType

      Type getUnderlyingType()
      Returns:
      the type that we immediately wrap. Used by Type.getUnwrappedType() to descend through all wrapped Type to find the first unwrapped one.
    • asStruct

      default Struct asStruct()
      Specified by:
      asStruct in interface Type
    • estimateSize

      default int estimateSize(Object entry)
      Description copied from interface: Type

      Estimate the number of bytes used to serialize the given value to an output stream.

      Specified by:
      estimateSize in interface Type
      Parameters:
      entry - the value of this type to measure. Must be of Type.internalType() or a ClassCastException is going to happen
      Returns:
      the estimated number of bytes, or zero if no estimation was possible.
    • toBytes

      default void toBytes(DataOutputStream os, Object toWrite) throws IOException
      Specified by:
      toBytes in interface Type
      Throws:
      IOException
    • fromBytes

      default Object fromBytes(DataInputStream in) throws IOException
      Specified by:
      fromBytes in interface Type
      Throws:
      IOException
    • isNullable

      default boolean isNullable()
      Specified by:
      isNullable in interface Type
      Returns:
      true if this type can be set to nothing TODO this might need to be final and do an instanceof check somewhere - we always want nullable to be on the outside
    • visit

      default <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