- java.lang.Object
-
- net.morimekta.providence.descriptor.PDeclaredDescriptor<T>
-
- net.morimekta.providence.descriptor.PMessageDescriptor<T,F>
-
- All Implemented Interfaces:
PDescriptor
- Direct Known Subclasses:
PExceptionDescriptor
,PStructDescriptor
,PUnionDescriptor
public abstract class PMessageDescriptor<T extends PMessage<T,F>,F extends PField> 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,F>> builderSupplier, boolean simple)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PMessageBuilder<T,F>
builder()
Get the builder for the given declared type.boolean
equals(java.lang.Object o)
F
fieldForId(int id)
F
fieldForName(java.lang.String name)
abstract F
findFieldById(int id)
abstract F
findFieldByName(java.lang.String name)
protected java.util.function.Supplier<PMessageBuilder<T,F>>
getBuilderSupplier()
Get the actual builder builderSupplier instance.F
getField(int key)
Deprecated.since 0.5.0.F
getField(java.lang.String name)
Deprecated.since 0.5.0.abstract F[]
getFields()
PType
getType()
abstract PMessageVariant
getVariant()
int
hashCode()
boolean
isSimple()
-
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,F>> builderSupplier, boolean simple)
-
-
Method Detail
-
getFields
@Nonnull public abstract F[] getFields()
- Returns:
- An unmodifiable list of fields that the struct holds.
-
findFieldByName
@Nullable public abstract F findFieldByName(java.lang.String name)
- Parameters:
name
- Name of field to get.- Returns:
- The field if present.
-
findFieldById
@Nullable public abstract F findFieldById(int id)
- Parameters:
id
- The ID of the field to get.- Returns:
- The field if present.
-
fieldForName
@Nonnull public F fieldForName(java.lang.String name)
- Parameters:
name
- The name of the field to get.- Returns:
- The field.
- Throws:
java.lang.IllegalArgumentException
- If not present.
-
fieldForId
@Nonnull public F fieldForId(int id)
- Parameters:
id
- The ID of the field to get.- Returns:
- The field.
- Throws:
java.lang.IllegalArgumentException
- If not present.
-
getField
@Deprecated public F getField(java.lang.String name)
Deprecated.since 0.5.0. UsefindFieldByName(String)
instead.- Parameters:
name
- Field name.- Returns:
- Field or null.
-
getField
@Deprecated public F getField(int key)
Deprecated.since 0.5.0. UsefindFieldById(int)
instead.- Parameters:
key
- Field key.- Returns:
- Field or null.
-
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,F> builder()
Description copied from class:PDeclaredDescriptor
Get the builder for the given declared 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
-
getBuilderSupplier
protected java.util.function.Supplier<PMessageBuilder<T,F>> getBuilderSupplier()
Get the actual builder builderSupplier instance. For contained structs only.- Returns:
- The builder builderSupplier.
-
-