Enum PPrimitive
- java.lang.Object
-
- java.lang.Enum<PPrimitive>
-
- net.morimekta.providence.descriptor.PPrimitive
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<PPrimitive>
,PDescriptor
public enum PPrimitive extends java.lang.Enum<PPrimitive> implements PDescriptor
Descriptors for primitive types.These are the basic types used in the thrift structure except containers.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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()
boolean
isNativePrimitive()
PPrimitiveProvider
provider()
Get the descriptor provider for the primitive.java.lang.String
toString()
static PPrimitive
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static PPrimitive[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
-
Methods inherited from interface net.morimekta.providence.descriptor.PDescriptor
getQualifiedName
-
-
-
-
Enum Constant 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
-
values
public static PPrimitive[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (PPrimitive c : PPrimitive.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static PPrimitive valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
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.Enum<PPrimitive>
-
getType
@Nonnull public PType getType()
- Specified by:
getType
in interfacePDescriptor
- Returns:
- Get the field type.
-
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(@Nonnull 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.
-
-