Class PMessageDescriptor<T extends PMessage<T>>
- java.lang.Object
-
- net.morimekta.providence.descriptor.PDeclaredDescriptor<T>
-
- net.morimekta.providence.descriptor.PMessageDescriptor<T>
-
- All Implemented Interfaces:
java.lang.reflect.Type
,PDescriptor
- Direct Known Subclasses:
PExceptionDescriptor
,PInterfaceDescriptor
,PStructDescriptor
,PUnionDescriptor
public abstract class PMessageDescriptor<T extends PMessage<T>> extends PDeclaredDescriptor<T>
Descriptor base class for all messages.
-
-
Constructor Summary
Constructors Constructor Description PMessageDescriptor(java.lang.String programName, java.lang.String name, java.util.function.Supplier<PMessageBuilder<T>> builderSupplier, boolean simple)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PMessageBuilder<T>
builder()
boolean
equals(java.lang.Object o)
PField<T>
fieldForId(int id)
PField<T>
fieldForName(java.lang.String name)
PField<T>
fieldForPojoName(java.lang.String pojoName)
abstract PField<T>
findFieldById(int id)
abstract PField<T>
findFieldByName(java.lang.String name)
abstract PField<T>
findFieldByPojoName(java.lang.String pojoName)
protected java.util.function.Supplier<PMessageBuilder<T>>
getBuilderSupplier()
Get the actual builder builderSupplier instance.abstract PField<T>[]
getFields()
PInterfaceDescriptor<?>
getImplementing()
Get interface descriptor this message implements.PType
getType()
abstract PMessageVariant
getVariant()
int
hashCode()
boolean
isSimple()
-
Methods inherited from class net.morimekta.providence.descriptor.PDeclaredDescriptor
getDefaultValue, getName, getProgramName, getQualifiedName, getTypeName, isAutoType, isInnerType, 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
-
-
-
-
Constructor Detail
-
PMessageDescriptor
public PMessageDescriptor(java.lang.String programName, java.lang.String name, java.util.function.Supplier<PMessageBuilder<T>> builderSupplier, boolean simple)
-
-
Method Detail
-
getFields
@Nonnull public abstract PField<T>[] getFields()
- Returns:
- An unmodifiable list of fields that the struct holds.
-
findFieldByName
@Nullable public abstract PField<T> findFieldByName(java.lang.String name)
- Parameters:
name
- Name of field to get.- Returns:
- The field if present.
-
findFieldByPojoName
public abstract PField<T> findFieldByPojoName(java.lang.String pojoName)
- Parameters:
pojoName
- POJO name of field.- Returns:
- The field if present.
-
findFieldById
@Nullable public abstract PField<T> findFieldById(int id)
- Parameters:
id
- The ID of the field to get.- Returns:
- The field if present.
-
fieldForName
@Nonnull public PField<T> fieldForName(java.lang.String name)
- Parameters:
name
- The name of the field to get.- Returns:
- The field.
- Throws:
java.lang.IllegalArgumentException
- If not present.
-
fieldForPojoName
@Nonnull public PField<T> fieldForPojoName(java.lang.String pojoName)
- Parameters:
pojoName
- The POJO name of the field to get.- Returns:
- The field.
- Throws:
java.lang.IllegalArgumentException
- If not present.
-
getImplementing
@Nullable public PInterfaceDescriptor<?> getImplementing()
Get interface descriptor this message implements.- Returns:
- The interface descriptor or null if not implementing declared interface.
-
fieldForId
@Nonnull public PField<T> fieldForId(int id)
- Parameters:
id
- The ID of the field to get.- Returns:
- The field.
- Throws:
java.lang.IllegalArgumentException
- If not present.
-
getVariant
@Nonnull public abstract PMessageVariant getVariant()
- Returns:
- The struct variant.
-
isSimple
public boolean isSimple()
- Returns:
- True if the message is simple. A simple message contains no containers, and no sub-messages.
-
getType
@Nonnull public PType getType()
- Returns:
- Get the field type.
-
builder
@Nonnull public PMessageBuilder<T> builder()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getBuilderSupplier
protected java.util.function.Supplier<PMessageBuilder<T>> getBuilderSupplier()
Get the actual builder builderSupplier instance. For contained structs only.- Returns:
- The builder builderSupplier.
-
-