Class CUnion.Builder
- java.lang.Object
-
- net.morimekta.providence.PMessageBuilder<CUnion>
-
- net.morimekta.providence.reflect.contained.CUnion.Builder
-
- All Implemented Interfaces:
PMessageOrBuilder<CUnion>
,PValue<CUnion>
- Enclosing class:
- CUnion
public static class CUnion.Builder extends PMessageBuilder<CUnion>
-
-
Constructor Summary
Constructors Constructor Description Builder(CUnion union)
Builder(CUnionDescriptor descriptor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CUnion.Builder
addTo(int key, java.lang.Object value)
Adds a value to a set or list container.CUnion
build()
CUnion.Builder
clear(int key)
Clear the provided field value.PUnionDescriptor<CUnion>
descriptor()
<T> T
get(int key)
boolean
has(int key)
boolean
isModified(int key)
Checks if a specific field is modified on the builder.boolean
isSet(int key)
Checks if a specific field is set on the builder.CUnion.Builder
merge(CUnion from)
Merges the provided message into the builder.PMessageBuilder<?>
mutator(int key)
Get the builder for the given message contained in this builder.CUnion.Builder
set(int key, java.lang.Object value)
Set the provided field value.boolean
valid()
Checks if the current set data is enough to make a valid struct.CUnion.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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.morimekta.providence.PMessageOrBuilder
get, has, toBuilder, toMessage
-
-
-
-
Constructor Detail
-
Builder
public Builder(CUnionDescriptor descriptor)
-
Builder
public Builder(CUnion union)
-
-
Method Detail
-
mutator
@Nonnull 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<CUnion>
- Parameters:
key
- The field key.- Returns:
- The field builder.
-
merge
@Nonnull public CUnion.Builder merge(@Nonnull CUnion 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<CUnion>
- Parameters:
from
- The message to merge values from.- Returns:
- The builder itself.
-
has
public boolean has(int key)
- Parameters:
key
- The key of the field.- Returns:
- Whether the field is present.
-
get
public <T> T get(int key)
- Type Parameters:
T
- The return type.- Parameters:
key
- The key of the field.- Returns:
- The value of the field.
-
descriptor
@Nonnull public PUnionDescriptor<CUnion> descriptor()
-
build
@Nonnull public CUnion build()
- Specified by:
build
in classPMessageBuilder<CUnion>
-
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<CUnion>
- Returns:
- True for a valid message.
-
validate
public CUnion.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<CUnion>
- Returns:
- The builder itself.
-
set
@Nonnull public CUnion.Builder set(int key, java.lang.Object value)
Description copied from class:PMessageBuilder
Set the provided field value.- Specified by:
set
in classPMessageBuilder<CUnion>
- 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<CUnion>
- 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<CUnion>
- Parameters:
key
- The key of the field to check.- Returns:
- True if the field is modified.
-
addTo
@Nonnull public CUnion.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<CUnion>
- Parameters:
key
- The key of the container field to add too.value
- The value to add.- Returns:
- The builder itself.
-
clear
@Nonnull public CUnion.Builder clear(int key)
Description copied from class:PMessageBuilder
Clear the provided field value.- Specified by:
clear
in classPMessageBuilder<CUnion>
- Parameters:
key
- The key of the field to clear.- Returns:
- The builder itself.
-
-