Package net.morimekta.providence.model
Class FieldType._Builder
- java.lang.Object
-
- net.morimekta.providence.PMessageBuilder<FieldType>
-
- net.morimekta.providence.model.FieldType._Builder
-
- All Implemented Interfaces:
Decl
,Decl._Builder
,FieldType_OrBuilder
,PMessageOrBuilder<FieldType>
,PValue<FieldType>
,BinaryReader
- Enclosing class:
- FieldType
public static class FieldType._Builder extends PMessageBuilder<FieldType> implements Decl._Builder, FieldType_OrBuilder, BinaryReader
For fields: (<key>:)? (required|optional)? <type> <name> (= <default_value>)? For const: const <type> <name> = <default_value>Fields without key is assigned values ranging from 65335 and down (2^16-1) in order of appearance. Because of the "in order of appearance" the field *must* be filled by the IDL parser.
Consts are always given the key '0'.
-
-
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FieldType._Builder
addTo(int key, java.lang.Object value)
Adds a value to a set or list container.FieldType
build()
FieldType._Builder
clear(int key)
Clear the provided field value.FieldType._Builder
clearAnnotations()
Clear theannotations
field.FieldType._Builder
clearDefaultValue()
Clear thedefault_value
field.FieldType._Builder
clearDocumentation()
Clear thedocumentation
field.FieldType._Builder
clearId()
Clear theid
field.FieldType._Builder
clearName()
Clear thename
field.FieldType._Builder
clearRequirement()
Clear therequirement
field.FieldType._Builder
clearType()
Clear thetype
field.PStructDescriptor<FieldType>
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
getDefaultValue()
java.lang.String
getDocumentation()
Documentation for the specific declaration.int
getId()
java.lang.String
getName()
Name of the type, constant or service.FieldRequirement
getRequirement()
java.lang.String
getType()
boolean
has(int key)
boolean
hasAnnotations()
Checks for presence of theannotations
field.boolean
hasDefaultValue()
Checks for presence of thedefault_value
field.boolean
hasDocumentation()
Checks for presence of thedocumentation
field.int
hashCode()
boolean
hasId()
Checks for presence of theid
field.boolean
hasName()
Checks for presence of thename
field.boolean
hasRequirement()
Checks for presence of therequirement
field.boolean
hasType()
Checks for presence of thetype
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
isModifiedDefaultValue()
Checks if thedefault_value
field has been modified since the builder was created.boolean
isModifiedDocumentation()
Checks if thedocumentation
field has been modified since the builder was created.boolean
isModifiedId()
Checks if theid
field has been modified since the builder was created.boolean
isModifiedName()
Checks if thename
field has been modified since the builder was created.boolean
isModifiedRequirement()
Checks if therequirement
field has been modified since the builder was created.boolean
isModifiedType()
Checks if thetype
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
isSetDefaultValue()
Checks for explicit presence of thedefault_value
field.boolean
isSetDocumentation()
Checks for explicit presence of thedocumentation
field.boolean
isSetId()
Checks for explicit presence of theid
field.boolean
isSetName()
Checks for explicit presence of thename
field.boolean
isSetRequirement()
Checks for explicit presence of therequirement
field.boolean
isSetType()
Checks for explicit presence of thetype
field.FieldType._Builder
merge(FieldType from)
Merges the provided message into the builder.java.util.Map<java.lang.String,java.lang.String>
mutableAnnotations()
PMessageBuilder
mutator(int key)
Get the builder for the given message contained in this builder.int
numAnnotations()
java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>
optionalAnnotations()
java.util.Optional<java.lang.String>
optionalDefaultValue()
java.util.Optional<java.lang.String>
optionalDocumentation()
Documentation for the specific declaration.java.util.Optional<FieldRequirement>
optionalRequirement()
FieldType._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.FieldType._Builder
set(int key, java.lang.Object value)
Set the provided field value.FieldType._Builder
setAnnotations(java.util.Map<java.lang.String,java.lang.String> value)
Set theannotations
field value.FieldType._Builder
setDefaultValue(java.lang.String value)
Set thedefault_value
field value.FieldType._Builder
setDocumentation(java.lang.String value)
Set thedocumentation
field value.FieldType._Builder
setId(int value)
Set theid
field value.FieldType._Builder
setId(java.lang.Integer value)
Set theid
field value.FieldType._Builder
setName(java.lang.String value)
Set thename
field value.FieldType._Builder
setRequirement(FieldRequirement value)
Set therequirement
field value.FieldType._Builder
setType(java.lang.String value)
Set thetype
field value.boolean
valid()
Checks if the current set data is enough to make a valid struct.FieldType._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, modifiedFieldNames, modifiedFields, mutator, presentFieldNames, 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.FieldType builder instance.
-
_Builder
public _Builder(FieldType base)
Make a mutating builder off a base p_model.FieldType.- Parameters:
base
- The base FieldType
-
-
Method Detail
-
merge
@Nonnull public FieldType._Builder merge(FieldType 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<FieldType>
- Parameters:
from
- The message to merge values from.- Returns:
- The builder itself.
-
setDocumentation
@Nonnull public FieldType._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 FieldType._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
-
setId
@Nonnull public FieldType._Builder setId(java.lang.Integer value)
Set theid
field value.- Parameters:
value
- The new value- Returns:
- The builder
-
setId
@Nonnull public FieldType._Builder setId(int value)
Set theid
field value.- Parameters:
value
- The new value- Returns:
- The builder
-
isSetId
public boolean isSetId()
Checks for explicit presence of theid
field.- Returns:
- True if id has been set.
-
hasId
public boolean hasId()
Checks for presence of theid
field.- Specified by:
hasId
in interfaceFieldType_OrBuilder
- Returns:
- True if id is present.
-
isModifiedId
public boolean isModifiedId()
Checks if theid
field has been modified since the builder was created.- Returns:
- True if id has been modified.
-
clearId
@Nonnull public FieldType._Builder clearId()
Clear theid
field.- Returns:
- The builder
-
getId
public int getId()
- Specified by:
getId
in interfaceFieldType_OrBuilder
- Returns:
- The
id
field value
-
setRequirement
@Nonnull public FieldType._Builder setRequirement(FieldRequirement value)
Set therequirement
field value.- Parameters:
value
- The new value- Returns:
- The builder
-
isSetRequirement
public boolean isSetRequirement()
Checks for explicit presence of therequirement
field.- Returns:
- True if requirement has been set.
-
hasRequirement
public boolean hasRequirement()
Checks for presence of therequirement
field.- Specified by:
hasRequirement
in interfaceFieldType_OrBuilder
- Returns:
- True if requirement is present.
-
isModifiedRequirement
public boolean isModifiedRequirement()
Checks if therequirement
field has been modified since the builder was created.- Returns:
- True if requirement has been modified.
-
clearRequirement
@Nonnull public FieldType._Builder clearRequirement()
Clear therequirement
field.- Returns:
- The builder
-
getRequirement
public FieldRequirement getRequirement()
- Specified by:
getRequirement
in interfaceFieldType_OrBuilder
- Returns:
- The
requirement
field value
-
optionalRequirement
@Nonnull public java.util.Optional<FieldRequirement> optionalRequirement()
- Specified by:
optionalRequirement
in interfaceFieldType_OrBuilder
- Returns:
- Optional
requirement
field value
-
setType
@Nonnull public FieldType._Builder setType(java.lang.String value)
Set thetype
field value.- Parameters:
value
- The new value- Returns:
- The builder
-
isSetType
public boolean isSetType()
Checks for explicit presence of thetype
field.- Returns:
- True if type has been set.
-
hasType
public boolean hasType()
Checks for presence of thetype
field.- Specified by:
hasType
in interfaceFieldType_OrBuilder
- Returns:
- True if type is present.
-
isModifiedType
public boolean isModifiedType()
Checks if thetype
field has been modified since the builder was created.- Returns:
- True if type has been modified.
-
clearType
@Nonnull public FieldType._Builder clearType()
Clear thetype
field.- Returns:
- The builder
-
getType
public java.lang.String getType()
- Specified by:
getType
in interfaceFieldType_OrBuilder
- Returns:
- The
type
field value
-
setName
@Nonnull public FieldType._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 FieldType._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.
-
setDefaultValue
@Nonnull public FieldType._Builder setDefaultValue(java.lang.String value)
Set thedefault_value
field value.- Parameters:
value
- The new value- Returns:
- The builder
-
isSetDefaultValue
public boolean isSetDefaultValue()
Checks for explicit presence of thedefault_value
field.- Returns:
- True if default_value has been set.
-
hasDefaultValue
public boolean hasDefaultValue()
Checks for presence of thedefault_value
field.- Specified by:
hasDefaultValue
in interfaceFieldType_OrBuilder
- Returns:
- True if default_value is present.
-
isModifiedDefaultValue
public boolean isModifiedDefaultValue()
Checks if thedefault_value
field has been modified since the builder was created.- Returns:
- True if default_value has been modified.
-
clearDefaultValue
@Nonnull public FieldType._Builder clearDefaultValue()
Clear thedefault_value
field.- Returns:
- The builder
-
getDefaultValue
public java.lang.String getDefaultValue()
- Specified by:
getDefaultValue
in interfaceFieldType_OrBuilder
- Returns:
- The
default_value
field value
-
optionalDefaultValue
@Nonnull public java.util.Optional<java.lang.String> optionalDefaultValue()
- Specified by:
optionalDefaultValue
in interfaceFieldType_OrBuilder
- Returns:
- Optional
default_value
field value
-
setAnnotations
@Nonnull public FieldType._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 FieldType._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 interfaceFieldType_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 FieldType._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 interfaceFieldType_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 interfaceFieldType_OrBuilder
- Returns:
- Optional
annotations
field value
-
numAnnotations
public int numAnnotations()
- Specified by:
numAnnotations
in interfaceFieldType_OrBuilder
- Returns:
- Number of entries in
annotations
.
-
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<FieldType>
- Parameters:
key
- The field key.- Returns:
- The field builder.
-
set
@Nonnull public FieldType._Builder set(int key, java.lang.Object value)
Description copied from class:PMessageBuilder
Set the provided field value.- Specified by:
set
in classPMessageBuilder<FieldType>
- 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<FieldType>
- 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<FieldType>
- 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<FieldType>
- 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<FieldType>
- Parameters:
key
- The key of the field.- Returns:
- Whether the field is present.
-
addTo
@Nonnull public FieldType._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<FieldType>
- Parameters:
key
- The key of the container field to add too.value
- The value to add.- Returns:
- The builder itself.
-
clear
@Nonnull public FieldType._Builder clear(int key)
Description copied from class:PMessageBuilder
Clear the provided field value.- Specified by:
clear
in classPMessageBuilder<FieldType>
- 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<FieldType>
- Returns:
- True for a valid message.
-
validate
public FieldType._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<FieldType>
- Returns:
- The builder itself.
-
descriptor
@Nonnull public PStructDescriptor<FieldType> descriptor()
- Specified by:
descriptor
in interfacePMessageOrBuilder<FieldType>
- Specified by:
descriptor
in interfacePValue<FieldType>
-
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 FieldType build()
- Specified by:
build
in interfaceDecl._Builder
- Specified by:
build
in classPMessageBuilder<FieldType>
- Returns:
- The built instance
-
-