Class PPrimitive
- java.lang.Object
-
- net.morimekta.providence.descriptor.PPrimitive
-
- All Implemented Interfaces:
PDescriptor
public class PPrimitive extends java.lang.Object implements PDescriptor
Descriptors for primitive types.These are the basic types used in the thrift structure except containers.
-
-
Field Summary
Fields Modifier and Type Field Description static PPrimitive
BINARY
static PPrimitive
BOOL
static PPrimitive
BYTE
static PPrimitive
DOUBLE
static PPrimitive
I16
static PPrimitive
I32
static PPrimitive
I64
static PPrimitive
STRING
static PPrimitive
VOID
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static PPrimitive
findByName(java.lang.String name)
Find primitive by name.java.lang.Object
getDefaultValue()
java.lang.String
getName()
The name of the type is the Identifier string from the IDL.java.lang.reflect.Type
getNativeType()
Get the java native type for the given primitive.java.lang.String
getProgramName()
The package name is derived form the .thrift file name that is parsed or if read from serialized format is explicit.java.lang.String
getQualifiedName(java.lang.String programContext)
This will return the qualified name of the type given the program context.PType
getType()
int
hashCode()
boolean
isNativePrimitive()
PPrimitiveProvider
provider()
Get the descriptor provider for the primitive.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.morimekta.providence.descriptor.PDescriptor
getQualifiedName
-
-
-
-
Field Detail
-
VOID
public static final PPrimitive VOID
-
BOOL
public static final PPrimitive BOOL
-
BYTE
public static final PPrimitive BYTE
-
I16
public static final PPrimitive I16
-
I32
public static final PPrimitive I32
-
I64
public static final PPrimitive I64
-
DOUBLE
public static final PPrimitive DOUBLE
-
STRING
public static final PPrimitive STRING
-
BINARY
public static final PPrimitive BINARY
-
-
Method Detail
-
provider
@Nonnull public PPrimitiveProvider provider()
Get the descriptor provider for the primitive.- Returns:
- The descriptor provider.
-
getProgramName
public java.lang.String getProgramName()
Description copied from interface:PDescriptor
The package name is derived form the .thrift file name that is parsed or if read from serialized format is explicit. Note that there may be package name conflicts globally.- Specified by:
getProgramName
in interfacePDescriptor
- Returns:
- The program name of the type. If empty the type is not in any named program, e.g. primitives.
-
getName
@Nonnull public java.lang.String getName()
Description copied from interface:PDescriptor
The name of the type is the Identifier string from the IDL.- Specified by:
getName
in interfacePDescriptor
- Returns:
- The name of the type. Not including package.
-
getQualifiedName
@Nonnull public java.lang.String getQualifiedName(java.lang.String programContext)
Description copied from interface:PDescriptor
This will return the qualified name of the type given the program context.- Specified by:
getQualifiedName
in interfacePDescriptor
- Parameters:
programContext
- The program which the type should be referenced from.- Returns:
- The qualified name of the type. Including program if not matching with programContext.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getType
@Nonnull public PType getType()
- Specified by:
getType
in interfacePDescriptor
- Returns:
- Get the field type.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getDefaultValue
public java.lang.Object getDefaultValue()
- Specified by:
getDefaultValue
in interfacePDescriptor
- Returns:
- The default value for the type used for default and required fields. Note that some primitive types don't support null values, and will have methods returning a default value regardless of the field required value setting.
-
isNativePrimitive
public boolean isNativePrimitive()
- Returns:
- Returns false if the primitive type allows null values. If this method returns true, getter and setter methods will have parameters and return type with the native primitive type, not it's boxed variant.
-
findByName
public static PPrimitive findByName(java.lang.String name)
Find primitive by name.- Parameters:
name
- The name of the primitive.- Returns:
- The primitive descriptor.
-
getNativeType
public java.lang.reflect.Type getNativeType()
Get the java native type for the given primitive.- Returns:
- The java type.
-
-