Package nz.org.riskscape.engine.types
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal Struct
asStruct()
final TypeIO
build
(Type type, TypeIOBuilder builder) construct
(TypeBuilder typeBuilder, AST.Symbol symbol) Attempt to build the type represented by thisTypeConstructor
final boolean
static final <T extends SimpleType>
TgetInstance
(Class<T> clazz) static final TypeInformation
getTypeInformation
(Class<? extends SimpleType> clazz) protected String
protected String
final int
hashCode()
static boolean
isSimpleType
(Type typeToTest) final String
toString()
<T,
U> U visit
(TypeVisitor<T, U> tv, T data) Type specific visiting logic.final Type
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface nz.org.riskscape.engine.types.Type
checkForNull, coerce, estimateSize, find, findAllowNull, fromBytes, getUnwrappedType, internalType, isA, isNullable, isNumeric, isWrapped, toBytes, toString, unwrap
Methods inherited from interface nz.org.riskscape.engine.typexp.TypeConstructor
construct
-
Field Details
-
DEFAULT_MEMBER_NAME
- See Also:
-
-
Constructor Details
-
SimpleType
public SimpleType()
-
-
Method Details
-
getInstance
- Returns:
- a singleton instance of a particular
SimpleType
.SimpleType
s only need one instance - this is their defining characteristic
-
getTypeInformation
- Returns:
- the
TypeInformation
for a particularSimpleType
class
-
isSimpleType
- Returns:
- true if typeToTest is a SimpleType, without any wrapping. A glorified
instanceof
, but wrapped in an API
-
equals
-
hashCode
public final int hashCode() -
asStruct
-
toString
-
build
- Specified by:
build
in interfaceTypeIOConstructor
-
writesType
- Specified by:
writesType
in interfaceTypeIO
- Returns:
- the exact type that this TypeIO can read/write
-
construct
Description copied from interface:TypeConstructor
Attempt to build the type represented by this
TypeConstructor
- Specified by:
construct
in interfaceTypeConstructor
- 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
- Returns:
- a description string to use for this
SimpleType
sTypeInformation
object.
-
getTypeInformationId
- Returns:
- an identifier for this
SimpleType
sTypeInformation
object.
-
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.
-