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._BuilderaddTo(int key, java.lang.Object value)Adds a value to a set or list container.Anybuild()Build the instance value.Any._Builderclear(int key)Clear the provided field value.Any._BuilderclearData()Clear thedatafield.Any._BuilderclearMediaType()Clear themedia_typefield.Any._BuilderclearText()Clear thetextfield.Any._BuilderclearType()Clear thetypefield.PStructDescriptor<Any,Any._Field>descriptor()Get the descriptor for the message being built.booleanequals(java.lang.Object o)net.morimekta.util.BinarygetData()The actual content binary data.java.lang.StringgetMediaType()The media type used for encoding.java.lang.StringgetText()Optional string encoded content for non-binary media types.java.lang.StringgetType()The thrift / providence program + message type name.inthashCode()booleanisModified(int key)Checks if a specific field is modified on the builder.booleanisModifiedData()Checks if thedatafield has been modified since the builder was created.booleanisModifiedMediaType()Checks if themedia_typefield has been modified since the builder was created.booleanisModifiedText()Checks if thetextfield has been modified since the builder was created.booleanisModifiedType()Checks if thetypefield has been modified since the builder was created.booleanisSet(int key)Checks if a specific field is set on the builder.booleanisSetData()Checks for presence of thedatafield.booleanisSetMediaType()Checks for presence of themedia_typefield.booleanisSetText()Checks for presence of thetextfield.booleanisSetType()Checks for presence of thetypefield.Any._Buildermerge(Any from)Merges the provided message into the builder.PMessageBuildermutator(int key)Get the builder for the given message contained in this builder.voidreadBinary(net.morimekta.util.io.BigEndianBinaryReader reader, boolean strict)Read the binary content into the current builder.Any._Builderset(int key, java.lang.Object value)Set the provided field value.Any._BuildersetData(net.morimekta.util.Binary value)Set thedatafield value.Any._BuildersetMediaType(java.lang.String value)Set themedia_typefield value.Any._BuildersetText(java.lang.String value)Set thetextfield value.Any._BuildersetType(java.lang.String value)Set thetypefield value.booleanvalid()Checks if the current set data is enough to make a valid struct.voidvalidate()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
-
-
-
-
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:PMessageBuilderMerges 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:
mergein 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 thetypefield 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 thetypefield.- Returns:
- True if type has been set.
-
isModifiedType
public boolean isModifiedType()
Checks if thetypefield has been modified since the builder was created.- Returns:
- True if type has been modified.
-
clearType
@Nonnull public Any._Builder clearType()
Clear thetypefield.- 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
typefield value
-
setMediaType
@Nonnull public Any._Builder setMediaType(java.lang.String value)
Set themedia_typefield 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_typefield.- Returns:
- True if media_type has been set.
-
isModifiedMediaType
public boolean isModifiedMediaType()
Checks if themedia_typefield has been modified since the builder was created.- Returns:
- True if media_type has been modified.
-
clearMediaType
@Nonnull public Any._Builder clearMediaType()
Clear themedia_typefield.- 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_typefield value
-
setData
@Nonnull public Any._Builder setData(net.morimekta.util.Binary value)
Set thedatafield value.The actual content binary data.
- Parameters:
value- The new value- Returns:
- The builder
-
isSetData
public boolean isSetData()
Checks for presence of thedatafield.- Returns:
- True if data has been set.
-
isModifiedData
public boolean isModifiedData()
Checks if thedatafield has been modified since the builder was created.- Returns:
- True if data has been modified.
-
clearData
@Nonnull public Any._Builder clearData()
Clear thedatafield.- Returns:
- The builder
-
getData
public net.morimekta.util.Binary getData()
The actual content binary data.- Returns:
- The
datafield value
-
setText
@Nonnull public Any._Builder setText(java.lang.String value)
Set thetextfield 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 thetextfield.- Returns:
- True if text has been set.
-
isModifiedText
public boolean isModifiedText()
Checks if thetextfield has been modified since the builder was created.- Returns:
- True if text has been modified.
-
clearText
@Nonnull public Any._Builder clearText()
Clear thetextfield.- 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
textfield value
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
mutator
public PMessageBuilder mutator(int key)
Description copied from class:PMessageBuilderGet 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:
mutatorin 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:PMessageBuilderSet the provided field value.- Specified by:
setin 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:PMessageBuilderChecks if a specific field is set on the builder.- Specified by:
isSetin 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:PMessageBuilderChecks if a specific field is modified on the builder.- Specified by:
isModifiedin 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:PMessageBuilderAdds a value to a set or list container.- Specified by:
addToin 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:PMessageBuilderClear the provided field value.- Specified by:
clearin 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:PMessageBuilderChecks 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:
validin classPMessageBuilder<Any,Any._Field>- Returns:
- True for a valid message.
-
validate
public void validate()
Description copied from class:PMessageBuilderChecks 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 anIllegalStateExceptionwith an appropriate error message.- Specified by:
validatein classPMessageBuilder<Any,Any._Field>
-
descriptor
@Nonnull public PStructDescriptor<Any,Any._Field> descriptor()
Description copied from class:PMessageBuilderGet the descriptor for the message being built.- Specified by:
descriptorin classPMessageBuilder<Any,Any._Field>- Returns:
- The struct descriptor.
-
readBinary
public void readBinary(net.morimekta.util.io.BigEndianBinaryReader reader, boolean strict) throws java.io.IOExceptionDescription copied from interface:BinaryReaderRead 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:
readBinaryin 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.
-
-