Package net.morimekta.providence.types
Class TypeReference
- java.lang.Object
-
- net.morimekta.providence.types.TypeReference
-
public final class TypeReference extends java.lang.Object
Simple class to represent a type reference or declaration reference (e.g. for constant, typedef etc).
-
-
Field Summary
Fields Modifier and Type Field Description TypeReference
keyType
java.lang.String
programName
java.lang.String
typeName
TypeReference
valueType
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
int
hashCode()
boolean
isContainer()
boolean
isList()
boolean
isMap()
boolean
isNativeType()
boolean
isSet()
static TypeReference
parseType(java.lang.String globalName)
Create a type reference from a global reference name.static TypeReference
parseType(java.lang.String programContext, java.lang.String typeName)
Create a type reference from a program context.static TypeReference
ref(java.lang.String programContext, java.lang.String typeName)
Create a simple type reference.java.lang.String
toString()
-
-
-
Field Detail
-
programName
public final java.lang.String programName
-
typeName
public final java.lang.String typeName
-
keyType
public final TypeReference keyType
-
valueType
public final TypeReference valueType
-
-
Method Detail
-
isNativeType
public boolean isNativeType()
-
isContainer
public boolean isContainer()
-
isList
public boolean isList()
-
isSet
public boolean isSet()
-
isMap
public boolean isMap()
-
ref
@Nonnull public static TypeReference ref(@Nonnull java.lang.String programContext, @Nonnull java.lang.String typeName)
Create a simple type reference. This can only contain simple (program, type) references. The type name can contain '.', but only for service request and response types.- Parameters:
programContext
- The local program context.typeName
- The type name.- Returns:
- The type reference.
-
parseType
@Nonnull public static TypeReference parseType(@Nonnull java.lang.String globalName)
Create a type reference from a global reference name. This must include a program name and a type name, and nothing else.- Parameters:
globalName
- The global type reference string.- Returns:
- The type reference.
-
parseType
@Nonnull public static TypeReference parseType(@Nonnull java.lang.String programContext, @Nonnull java.lang.String typeName)
Create a type reference from a program context. If the type name contains it's own program name (program.Type) then that program name is used, otherwise the local program context is used.- Parameters:
programContext
- The local program context.typeName
- The type name.- Returns:
- The type reference.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-