Package nz.org.riskscape.engine.types
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
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 Summary
Modifier and TypeMethodDescriptiondefault Struct
asStruct()
default int
estimateSize
(Object entry) Estimate the number of bytes used to serialize the given value to an output stream.default Object
default boolean
default void
toBytes
(DataOutputStream os, Object toWrite) default <T,
U> U visit
(TypeVisitor<T, U> tv, T data) Type specific visiting logic.Methods inherited from interface nz.org.riskscape.engine.types.Type
checkForNull, coerce, find, findAllowNull, getUnwrappedType, internalType, isA, isNumeric, isWrapped, toString, unwrap
-
Method Details
-
getUnderlyingType
Type getUnderlyingType()- Returns:
- the type that we immediately wrap. Used by
Type.getUnwrappedType()
to descend through all wrappedType
to find the first unwrapped one.
-
asStruct
-
estimateSize
Description copied from interface:Type
Estimate the number of bytes used to serialize the given value to an output stream.
- Specified by:
estimateSize
in interfaceType
- Parameters:
entry
- the value of this type to measure. Must be ofType.internalType()
or aClassCastException
is going to happen- Returns:
- the estimated number of bytes, or zero if no estimation was possible.
-
toBytes
- Specified by:
toBytes
in interfaceType
- Throws:
IOException
-
fromBytes
- Specified by:
fromBytes
in interfaceType
- Throws:
IOException
-
isNullable
default boolean isNullable()- Specified by:
isNullable
in interfaceType
- 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
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.
-