Package net.morimekta.providence.model
Class MessageType._Builder
- java.lang.Object
-
- net.morimekta.providence.PMessageBuilder<MessageType>
-
- net.morimekta.providence.model.MessageType._Builder
-
- All Implemented Interfaces:
Decl
,Decl._Builder
,MessageType_OrBuilder
,PMessageOrBuilder<MessageType>
,PValue<MessageType>
,BinaryReader
- Enclosing class:
- MessageType
public static class MessageType._Builder extends PMessageBuilder<MessageType> implements Decl._Builder, MessageType_OrBuilder, BinaryReader
<variant> { (<field> ([,;])?)* }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.morimekta.providence.model.Decl
Decl._Builder, Decl._Field
-
-
Field Summary
-
Fields inherited from interface net.morimekta.providence.model.Decl
kDescriptor
-
-
Constructor Summary
Constructors Constructor Description _Builder()
Make a p_model.MessageType builder instance._Builder(MessageType base)
Make a mutating builder off a base p_model.MessageType.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageType._Builder
addTo(int key, java.lang.Object value)
Adds a value to a set or list container.MessageType._Builder
addToFields(FieldType... values)
Adds entries to thefields
list.MessageType
build()
MessageType._Builder
clear(int key)
Clear the provided field value.MessageType._Builder
clearAnnotations()
Clear theannotations
field.MessageType._Builder
clearDocumentation()
Clear thedocumentation
field.MessageType._Builder
clearFields()
Clear thefields
field.MessageType._Builder
clearImplementing()
Clear theimplementing
field.MessageType._Builder
clearName()
Clear thename
field.MessageType._Builder
clearVariant()
Clear thevariant
field.PStructDescriptor<MessageType>
descriptor()
boolean
equals(java.lang.Object o)
<T> T
get(int key)
java.util.Map<java.lang.String,java.lang.String>
getAnnotations()
java.lang.String
getDocumentation()
Documentation for the specific declaration.java.util.List<FieldType>
getFields()
java.lang.String
getImplementing()
Interface this message is implementing.java.lang.String
getName()
Name of the type, constant or service.MessageVariant
getVariant()
boolean
has(int key)
boolean
hasAnnotations()
Checks for presence of theannotations
field.boolean
hasDocumentation()
Checks for presence of thedocumentation
field.boolean
hasFields()
Checks for presence of thefields
field.int
hashCode()
boolean
hasImplementing()
Checks for presence of theimplementing
field.boolean
hasName()
Checks for presence of thename
field.boolean
hasVariant()
Checks for presence of thevariant
field.boolean
isModified(int key)
Checks if a specific field is modified on the builder.boolean
isModifiedAnnotations()
Checks if theannotations
field has been modified since the builder was created.boolean
isModifiedDocumentation()
Checks if thedocumentation
field has been modified since the builder was created.boolean
isModifiedFields()
Checks if thefields
field has been modified since the builder was created.boolean
isModifiedImplementing()
Checks if theimplementing
field has been modified since the builder was created.boolean
isModifiedName()
Checks if thename
field has been modified since the builder was created.boolean
isModifiedVariant()
Checks if thevariant
field has been modified since the builder was created.boolean
isSet(int key)
Checks if a specific field is set on the builder.boolean
isSetAnnotations()
Checks for explicit presence of theannotations
field.boolean
isSetDocumentation()
Checks for explicit presence of thedocumentation
field.boolean
isSetFields()
Checks for explicit presence of thefields
field.boolean
isSetImplementing()
Checks for explicit presence of theimplementing
field.boolean
isSetName()
Checks for explicit presence of thename
field.boolean
isSetVariant()
Checks for explicit presence of thevariant
field.MessageType._Builder
merge(MessageType from)
Merges the provided message into the builder.java.util.Map<java.lang.String,java.lang.String>
mutableAnnotations()
java.util.List<FieldType>
mutableFields()
PMessageBuilder
mutator(int key)
Get the builder for the given message contained in this builder.int
numAnnotations()
int
numFields()
java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>
optionalAnnotations()
java.util.Optional<java.lang.String>
optionalDocumentation()
Documentation for the specific declaration.java.util.Optional<java.lang.String>
optionalImplementing()
Interface this message is implementing.java.util.Optional<MessageVariant>
optionalVariant()
MessageType._Builder
putInAnnotations(java.lang.String key, java.lang.String value)
Adds a mapping to theannotations
map.void
readBinary(net.morimekta.util.io.BigEndianBinaryReader reader, boolean strict)
Read the binary content into the current builder.MessageType._Builder
set(int key, java.lang.Object value)
Set the provided field value.MessageType._Builder
setAnnotations(java.util.Map<java.lang.String,java.lang.String> value)
Set theannotations
field value.MessageType._Builder
setDocumentation(java.lang.String value)
Set thedocumentation
field value.MessageType._Builder
setFields(java.util.Collection<FieldType> value)
Set thefields
field value.MessageType._Builder
setImplementing(java.lang.String value)
Set theimplementing
field value.MessageType._Builder
setName(java.lang.String value)
Set thename
field value.MessageType._Builder
setVariant(MessageVariant value)
Set thevariant
field value.boolean
valid()
Checks if the current set data is enough to make a valid struct.MessageType._Builder
validate()
Checks if the current set data is enough to make a valid struct.-
Methods inherited from class net.morimekta.providence.PMessageBuilder
addTo, clear, isModified, isSet, modifiedFields, mutator, presentFields, set
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.morimekta.providence.PMessageOrBuilder
get, has, toBuilder, toMessage
-
-
-
-
Constructor Detail
-
_Builder
public _Builder()
Make a p_model.MessageType builder instance.
-
_Builder
public _Builder(MessageType base)
Make a mutating builder off a base p_model.MessageType.- Parameters:
base
- The base MessageType
-
-
Method Detail
-
merge
@Nonnull public MessageType._Builder merge(MessageType from)
Description copied from class:PMessageBuilder
Merges the provided message into the builder. Contained messages should in turn be merged and not replaced wholesale. Sets are unioned (addAll) and maps will overwrite / replace on a per-key basis (putAll).- Specified by:
merge
in classPMessageBuilder<MessageType>
- Parameters:
from
- The message to merge values from.- Returns:
- The builder itself.
-
setDocumentation
@Nonnull public MessageType._Builder setDocumentation(java.lang.String value)
Set thedocumentation
field value.- Specified by:
setDocumentation
in interfaceDecl._Builder
- Parameters:
value
- The new value- Returns:
- The builder
-
isSetDocumentation
public boolean isSetDocumentation()
Checks for explicit presence of thedocumentation
field.- Returns:
- True if documentation has been set.
-
hasDocumentation
public boolean hasDocumentation()
Checks for presence of thedocumentation
field.- Specified by:
hasDocumentation
in interfaceDecl
- Returns:
- True if documentation is present.
-
isModifiedDocumentation
public boolean isModifiedDocumentation()
Checks if thedocumentation
field has been modified since the builder was created.- Returns:
- True if documentation has been modified.
-
clearDocumentation
@Nonnull public MessageType._Builder clearDocumentation()
Clear thedocumentation
field.- Specified by:
clearDocumentation
in interfaceDecl._Builder
- Returns:
- The builder
-
getDocumentation
public java.lang.String getDocumentation()
Description copied from interface:Decl
Documentation for the specific declaration.- Specified by:
getDocumentation
in interfaceDecl
- Returns:
- The
documentation
field value
-
optionalDocumentation
@Nonnull public java.util.Optional<java.lang.String> optionalDocumentation()
Description copied from interface:Decl
Documentation for the specific declaration.- Specified by:
optionalDocumentation
in interfaceDecl
- Returns:
- Optional
documentation
field value
-
setVariant
@Nonnull public MessageType._Builder setVariant(MessageVariant value)
Set thevariant
field value.- Parameters:
value
- The new value- Returns:
- The builder
-
isSetVariant
public boolean isSetVariant()
Checks for explicit presence of thevariant
field.- Returns:
- True if variant has been set.
-
hasVariant
public boolean hasVariant()
Checks for presence of thevariant
field.- Specified by:
hasVariant
in interfaceMessageType_OrBuilder
- Returns:
- True if variant is present.
-
isModifiedVariant
public boolean isModifiedVariant()
Checks if thevariant
field has been modified since the builder was created.- Returns:
- True if variant has been modified.
-
clearVariant
@Nonnull public MessageType._Builder clearVariant()
Clear thevariant
field.- Returns:
- The builder
-
getVariant
public MessageVariant getVariant()
- Specified by:
getVariant
in interfaceMessageType_OrBuilder
- Returns:
- The
variant
field value
-
optionalVariant
@Nonnull public java.util.Optional<MessageVariant> optionalVariant()
- Specified by:
optionalVariant
in interfaceMessageType_OrBuilder
- Returns:
- Optional
variant
field value
-
setName
@Nonnull public MessageType._Builder setName(java.lang.String value)
Set thename
field value.- Specified by:
setName
in interfaceDecl._Builder
- Parameters:
value
- The new value- Returns:
- The builder
-
isSetName
public boolean isSetName()
Checks for explicit presence of thename
field.- Returns:
- True if name has been set.
-
hasName
public boolean hasName()
Checks for presence of thename
field.
-
isModifiedName
public boolean isModifiedName()
Checks if thename
field has been modified since the builder was created.- Returns:
- True if name has been modified.
-
clearName
@Nonnull public MessageType._Builder clearName()
Clear thename
field.- Specified by:
clearName
in interfaceDecl._Builder
- Returns:
- The builder
-
getName
public java.lang.String getName()
Description copied from interface:Decl
Name of the type, constant or service.
-
setFields
@Nonnull public MessageType._Builder setFields(java.util.Collection<FieldType> value)
Set thefields
field value.- Parameters:
value
- The new value- Returns:
- The builder
-
addToFields
@Nonnull public MessageType._Builder addToFields(FieldType... values)
Adds entries to thefields
list.- Parameters:
values
- The added value- Returns:
- The builder
-
isSetFields
public boolean isSetFields()
Checks for explicit presence of thefields
field.- Returns:
- True if fields has been set.
-
hasFields
public boolean hasFields()
Checks for presence of thefields
field.- Specified by:
hasFields
in interfaceMessageType_OrBuilder
- Returns:
- True if fields is present.
-
isModifiedFields
public boolean isModifiedFields()
Checks if thefields
field has been modified since the builder was created.- Returns:
- True if fields has been modified.
-
clearFields
@Nonnull public MessageType._Builder clearFields()
Clear thefields
field.- Returns:
- The builder
-
mutableFields
public java.util.List<FieldType> mutableFields()
- Returns:
- The mutable
fields
container
-
getFields
public java.util.List<FieldType> getFields()
- Specified by:
getFields
in interfaceMessageType_OrBuilder
- Returns:
- The
fields
field value
-
numFields
public int numFields()
- Specified by:
numFields
in interfaceMessageType_OrBuilder
- Returns:
- Number of entries in
fields
.
-
setAnnotations
@Nonnull public MessageType._Builder setAnnotations(java.util.Map<java.lang.String,java.lang.String> value)
Set theannotations
field value.- Parameters:
value
- The new value- Returns:
- The builder
-
putInAnnotations
@Nonnull public MessageType._Builder putInAnnotations(java.lang.String key, java.lang.String value)
Adds a mapping to theannotations
map.- Parameters:
key
- The inserted keyvalue
- The inserted value- Returns:
- The builder
-
isSetAnnotations
public boolean isSetAnnotations()
Checks for explicit presence of theannotations
field.- Returns:
- True if annotations has been set.
-
hasAnnotations
public boolean hasAnnotations()
Checks for presence of theannotations
field.- Specified by:
hasAnnotations
in interfaceMessageType_OrBuilder
- Returns:
- True if annotations is present.
-
isModifiedAnnotations
public boolean isModifiedAnnotations()
Checks if theannotations
field has been modified since the builder was created.- Returns:
- True if annotations has been modified.
-
clearAnnotations
@Nonnull public MessageType._Builder clearAnnotations()
Clear theannotations
field.- Returns:
- The builder
-
mutableAnnotations
public java.util.Map<java.lang.String,java.lang.String> mutableAnnotations()
- Returns:
- The mutable
annotations
container
-
getAnnotations
public java.util.Map<java.lang.String,java.lang.String> getAnnotations()
- Specified by:
getAnnotations
in interfaceMessageType_OrBuilder
- Returns:
- The
annotations
field value
-
optionalAnnotations
@Nonnull public java.util.Optional<java.util.Map<java.lang.String,java.lang.String>> optionalAnnotations()
- Specified by:
optionalAnnotations
in interfaceMessageType_OrBuilder
- Returns:
- Optional
annotations
field value
-
numAnnotations
public int numAnnotations()
- Specified by:
numAnnotations
in interfaceMessageType_OrBuilder
- Returns:
- Number of entries in
annotations
.
-
setImplementing
@Nonnull public MessageType._Builder setImplementing(java.lang.String value)
Set theimplementing
field value.Interface this message is implementing.
- Parameters:
value
- The new value- Returns:
- The builder
-
isSetImplementing
public boolean isSetImplementing()
Checks for explicit presence of theimplementing
field.- Returns:
- True if implementing has been set.
-
hasImplementing
public boolean hasImplementing()
Checks for presence of theimplementing
field.- Specified by:
hasImplementing
in interfaceMessageType_OrBuilder
- Returns:
- True if implementing is present.
-
isModifiedImplementing
public boolean isModifiedImplementing()
Checks if theimplementing
field has been modified since the builder was created.- Returns:
- True if implementing has been modified.
-
clearImplementing
@Nonnull public MessageType._Builder clearImplementing()
Clear theimplementing
field.- Returns:
- The builder
-
getImplementing
public java.lang.String getImplementing()
Interface this message is implementing.- Specified by:
getImplementing
in interfaceMessageType_OrBuilder
- Returns:
- The
implementing
field value
-
optionalImplementing
@Nonnull public java.util.Optional<java.lang.String> optionalImplementing()
Interface this message is implementing.- Specified by:
optionalImplementing
in interfaceMessageType_OrBuilder
- Returns:
- Optional
implementing
field value
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
mutator
public PMessageBuilder mutator(int key)
Description copied from class:PMessageBuilder
Get the builder for the given message contained in this builder. If the sub-builder does not exist, create, either from existing instance or from scratch.- Specified by:
mutator
in classPMessageBuilder<MessageType>
- Parameters:
key
- The field key.- Returns:
- The field builder.
-
set
@Nonnull public MessageType._Builder set(int key, java.lang.Object value)
Description copied from class:PMessageBuilder
Set the provided field value.- Specified by:
set
in classPMessageBuilder<MessageType>
- Parameters:
key
- The key of the field to set.value
- The value to be set.- Returns:
- The message builder.
-
isSet
public boolean isSet(int key)
Description copied from class:PMessageBuilder
Checks if a specific field is set on the builder.- Specified by:
isSet
in classPMessageBuilder<MessageType>
- Parameters:
key
- The key of the field to check.- Returns:
- True if the field is set.
-
isModified
public boolean isModified(int key)
Description copied from class:PMessageBuilder
Checks if a specific field is modified on the builder.- Specified by:
isModified
in classPMessageBuilder<MessageType>
- Parameters:
key
- The key of the field to check.- Returns:
- True if the field is modified.
-
get
public <T> T get(int key)
- Specified by:
get
in interfacePMessageOrBuilder<MessageType>
- Type Parameters:
T
- The return type.- Parameters:
key
- The key of the field.- Returns:
- The value of the field.
-
has
public boolean has(int key)
- Specified by:
has
in interfacePMessageOrBuilder<MessageType>
- Parameters:
key
- The key of the field.- Returns:
- Whether the field is present.
-
addTo
@Nonnull public MessageType._Builder addTo(int key, java.lang.Object value)
Description copied from class:PMessageBuilder
Adds a value to a set or list container.- Specified by:
addTo
in classPMessageBuilder<MessageType>
- Parameters:
key
- The key of the container field to add too.value
- The value to add.- Returns:
- The builder itself.
-
clear
@Nonnull public MessageType._Builder clear(int key)
Description copied from class:PMessageBuilder
Clear the provided field value.- Specified by:
clear
in classPMessageBuilder<MessageType>
- Parameters:
key
- The key of the field to clear.- Returns:
- The builder itself.
-
valid
public boolean valid()
Description copied from class:PMessageBuilder
Checks if the current set data is enough to make a valid struct. It will check for all required fields, and if any are missing it will return false.- Specified by:
valid
in classPMessageBuilder<MessageType>
- Returns:
- True for a valid message.
-
validate
public MessageType._Builder validate()
Description copied from class:PMessageBuilder
Checks if the current set data is enough to make a valid struct. It will check for all required fields, and if any are missing it will throw anIllegalStateException
with an appropriate error message.- Specified by:
validate
in classPMessageBuilder<MessageType>
- Returns:
- The builder itself.
-
descriptor
@Nonnull public PStructDescriptor<MessageType> descriptor()
- Specified by:
descriptor
in interfacePMessageOrBuilder<MessageType>
- Specified by:
descriptor
in interfacePValue<MessageType>
-
readBinary
public void readBinary(net.morimekta.util.io.BigEndianBinaryReader reader, boolean strict) throws java.io.IOException
Description copied from interface:BinaryReader
Read the binary content into the current builder. NOTE: This method is not intended to be used directly. Instead use theBinarySerializer.deserialize(InputStream, PMessageDescriptor)
call.- Specified by:
readBinary
in interfaceBinaryReader
- Parameters:
reader
- The reader to read from.strict
- If content should be handled strictly. True means to fail on everything that Apache thrift failed read() on.- Throws:
java.io.IOException
- When unable to read message for any reason.
-
build
@Nonnull public MessageType build()
- Specified by:
build
in interfaceDecl._Builder
- Specified by:
build
in classPMessageBuilder<MessageType>
- Returns:
- The built instance
-
-