Package net.morimekta.providence.util
Class Any._Builder
- java.lang.Object
-
- net.morimekta.providence.PMessageBuilder<Any,Any._Field>
-
- net.morimekta.providence.util.Any._Builder
-
- All Implemented Interfaces:
PBuilder<Any>
,BinaryReader
- Enclosing class:
- Any
public static class Any._Builder extends PMessageBuilder<Any,Any._Field> implements BinaryReader
A message containing anything.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Any._Builder
addTo(int key, java.lang.Object value)
Adds a value to a set or list container.Any
build()
Build the instance value.Any._Builder
clear(int key)
Clear the provided field value.Any._Builder
clearData()
Clear thedata
field.Any._Builder
clearMediaType()
Clear themedia_type
field.Any._Builder
clearText()
Clear thetext
field.Any._Builder
clearType()
Clear thetype
field.PStructDescriptor<Any,Any._Field>
descriptor()
Get the descriptor for the message being built.boolean
equals(java.lang.Object o)
net.morimekta.util.Binary
getData()
The actual content binary data.java.lang.String
getMediaType()
The media type used for encoding.java.lang.String
getText()
Optional string encoded content for non-binary media types.java.lang.String
getType()
The thrift / providence program + message type name.int
hashCode()
boolean
isModified(int key)
Checks if a specific field is modified on the builder.boolean
isModifiedData()
Checks if thedata
field has been modified since the builder was created.boolean
isModifiedMediaType()
Checks if themedia_type
field has been modified since the builder was created.boolean
isModifiedText()
Checks if thetext
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
isSetData()
Checks for presence of thedata
field.boolean
isSetMediaType()
Checks for presence of themedia_type
field.boolean
isSetText()
Checks for presence of thetext
field.boolean
isSetType()
Checks for presence of thetype
field.Any._Builder
merge(Any from)
Merges the provided message into the builder.PMessageBuilder
mutator(int key)
Get the builder for the given message contained in this builder.void
readBinary(net.morimekta.util.io.BigEndianBinaryReader reader, boolean strict)
Read the binary content into the current builder.Any._Builder
set(int key, java.lang.Object value)
Set the provided field value.Any._Builder
setData(net.morimekta.util.Binary value)
Set thedata
field value.Any._Builder
setMediaType(java.lang.String value)
Set themedia_type
field value.Any._Builder
setText(java.lang.String value)
Set thetext
field value.Any._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.void
validate()
Checks if the current set data is enough to make a valid struct.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from class net.morimekta.providence.PMessageBuilder
addTo, clear, isModified, isSet, modifiedFields, mutator, presentFields, set
-
-
-
-
Constructor Detail
-
_Builder
public _Builder()
Make a putil.Any builder instance.
-
_Builder
public _Builder(Any base)
Make a mutating builder off a base putil.Any.- Parameters:
base
- The base Any
-
-
Method Detail
-
merge
@Nonnull public Any._Builder merge(Any 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<Any,Any._Field>
- Parameters:
from
- The message to merge values from.- Returns:
- The message builder.
-
setType
@Nonnull public Any._Builder setType(java.lang.String value)
Set thetype
field value.The thrift / providence program + message type name. This should refer to a message type. Enums will need to be wrapped in a message to be contained.
- Parameters:
value
- The new value- Returns:
- The builder
-
isSetType
public boolean isSetType()
Checks for presence of thetype
field.- Returns:
- True if type has been set.
-
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 Any._Builder clearType()
Clear thetype
field.- Returns:
- The builder
-
getType
public java.lang.String getType()
The thrift / providence program + message type name. This should refer to a message type. Enums will need to be wrapped in a message to be contained.- Returns:
- The
type
field value
-
setMediaType
@Nonnull public Any._Builder setMediaType(java.lang.String value)
Set themedia_type
field value.The media type used for encoding. There will need to exist a serializer registered for this. If the media type is not set, it is assumed to be 'application/vnd.apache.thrift.binary', the default thrift serialization.
- Parameters:
value
- The new value- Returns:
- The builder
-
isSetMediaType
public boolean isSetMediaType()
Checks for presence of themedia_type
field.- Returns:
- True if media_type has been set.
-
isModifiedMediaType
public boolean isModifiedMediaType()
Checks if themedia_type
field has been modified since the builder was created.- Returns:
- True if media_type has been modified.
-
clearMediaType
@Nonnull public Any._Builder clearMediaType()
Clear themedia_type
field.- Returns:
- The builder
-
getMediaType
public java.lang.String getMediaType()
The media type used for encoding. There will need to exist a serializer registered for this. If the media type is not set, it is assumed to be 'application/vnd.apache.thrift.binary', the default thrift serialization.- Returns:
- The
media_type
field value
-
setData
@Nonnull public Any._Builder setData(net.morimekta.util.Binary value)
Set thedata
field value.The actual content binary data.
- Parameters:
value
- The new value- Returns:
- The builder
-
isSetData
public boolean isSetData()
Checks for presence of thedata
field.- Returns:
- True if data has been set.
-
isModifiedData
public boolean isModifiedData()
Checks if thedata
field has been modified since the builder was created.- Returns:
- True if data has been modified.
-
clearData
@Nonnull public Any._Builder clearData()
Clear thedata
field.- Returns:
- The builder
-
getData
public net.morimekta.util.Binary getData()
The actual content binary data.- Returns:
- The
data
field value
-
setText
@Nonnull public Any._Builder setText(java.lang.String value)
Set thetext
field value.Optional string encoded content for non-binary media types. If this is filled in, then the 'bin' field is not needed.
- Parameters:
value
- The new value- Returns:
- The builder
-
isSetText
public boolean isSetText()
Checks for presence of thetext
field.- Returns:
- True if text has been set.
-
isModifiedText
public boolean isModifiedText()
Checks if thetext
field has been modified since the builder was created.- Returns:
- True if text has been modified.
-
clearText
@Nonnull public Any._Builder clearText()
Clear thetext
field.- Returns:
- The builder
-
getText
public java.lang.String getText()
Optional string encoded content for non-binary media types. If this is filled in, then the 'bin' field is not needed.- Returns:
- The
text
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<Any,Any._Field>
- Parameters:
key
- The field key.- Returns:
- The field builder.
-
set
@Nonnull public Any._Builder set(int key, java.lang.Object value)
Description copied from class:PMessageBuilder
Set the provided field value.- Specified by:
set
in classPMessageBuilder<Any,Any._Field>
- 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<Any,Any._Field>
- 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<Any,Any._Field>
- Parameters:
key
- The key of the field to check.- Returns:
- True if the field is modified.
-
addTo
@Nonnull public Any._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<Any,Any._Field>
- Parameters:
key
- The key of the container field to add too.value
- The value to add.- Returns:
- The message builder.
-
clear
@Nonnull public Any._Builder clear(int key)
Description copied from class:PMessageBuilder
Clear the provided field value.- Specified by:
clear
in classPMessageBuilder<Any,Any._Field>
- Parameters:
key
- The key of the field to clear.- Returns:
- The message builder.
-
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<Any,Any._Field>
- Returns:
- True for a valid message.
-
validate
public void 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<Any,Any._Field>
-
descriptor
@Nonnull public PStructDescriptor<Any,Any._Field> descriptor()
Description copied from class:PMessageBuilder
Get the descriptor for the message being built.- Specified by:
descriptor
in classPMessageBuilder<Any,Any._Field>
- Returns:
- The struct descriptor.
-
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.
-
-