Class PMessageDescriptor<T extends PMessage<T>>
- java.lang.Object
-
- net.morimekta.providence.descriptor.PDeclaredDescriptor<T>
-
- net.morimekta.providence.descriptor.PMessageDescriptor<T>
-
- All Implemented Interfaces:
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()Get the builder for the given declared type.booleanequals(java.lang.Object o)PField<T>fieldForId(int id)PField<T>fieldForName(java.lang.String name)abstract PField<T>findFieldById(int id)abstract PField<T>findFieldByName(java.lang.String name)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.PTypegetType()abstract PMessageVariantgetVariant()inthashCode()booleanisSimple()-
Methods inherited from class net.morimekta.providence.descriptor.PDeclaredDescriptor
getDefaultValue, getName, getProgramName, getQualifiedName, 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.
-
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.
-
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()
Description copied from class:PDeclaredDescriptorGet the builder for the given declared type.- Specified by:
builderin classPDeclaredDescriptor<T extends PMessage<T>>- Returns:
- The type specific builder provider.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein 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.
-
-