net.morimekta.providence.model.EnumValue Maven / Gradle / Ivy
package net.morimekta.providence.model;
/**
* <name> (= <value>)
*/
@SuppressWarnings("unused")
@javax.annotation.Generated(
value = "net.morimekta.providence:providence-generator-java",
comments = "java:serializable")
@javax.annotation.concurrent.Immutable
public class EnumValue
implements net.morimekta.providence.model.Decl,
EnumValue_OrBuilder,
net.morimekta.providence.PMessage,
Comparable,
java.io.Serializable,
net.morimekta.providence.serializer.binary.BinaryWriter {
private final static String kDefaultName = "";
private final static int kDefaultId = 0;
private final static long serialVersionUID = -848696122454292624L;
private final transient String mDocumentation;
private final transient String mName;
private final transient Integer mId;
private final transient java.util.Map mAnnotations;
private volatile transient int tHashCode;
// Transient object used during java deserialization.
private transient EnumValue tSerializeInstance;
private EnumValue(_Builder builder) {
mDocumentation = builder.mDocumentation;
if (builder.isSetName()) {
mName = builder.mName;
} else {
mName = kDefaultName;
}
mId = builder.mId;
if (builder.isSetAnnotations()) {
mAnnotations = net.morimekta.util.collect.UnmodifiableSortedMap.copyOf(builder.mAnnotations);
} else {
mAnnotations = null;
}
}
public boolean hasDocumentation() {
return mDocumentation != null;
}
/**
* @return The documentation
value
*/
public String getDocumentation() {
return mDocumentation;
}
/**
* @return Optional of the documentation
field value.
*/
@javax.annotation.Nonnull
public java.util.Optional optionalDocumentation() {
return java.util.Optional.ofNullable(mDocumentation);
}
public boolean hasName() {
return true;
}
/**
* @return The name
value
*/
@javax.annotation.Nonnull
public String getName() {
return mName;
}
public boolean hasId() {
return mId != null;
}
/**
* @return The id
value
*/
public int getId() {
return hasId() ? mId : kDefaultId;
}
/**
* @return Optional of the id
field value.
*/
@javax.annotation.Nonnull
public java.util.Optional optionalId() {
return java.util.Optional.ofNullable(mId);
}
public int numAnnotations() {
return mAnnotations != null ? mAnnotations.size() : 0;
}
public boolean hasAnnotations() {
return mAnnotations != null;
}
/**
* @return The annotations
value
*/
public java.util.Map getAnnotations() {
return mAnnotations;
}
/**
* @return Optional of the annotations
field value.
*/
@javax.annotation.Nonnull
public java.util.Optional> optionalAnnotations() {
return java.util.Optional.ofNullable(mAnnotations);
}
@Override
public boolean has(int key) {
switch(key) {
case 1: return mDocumentation != null;
case 2: return true;
case 3: return mId != null;
case 4: return mAnnotations != null;
default: return false;
}
}
@Override
@SuppressWarnings("unchecked")
public T get(int key) {
switch(key) {
case 1: return (T) mDocumentation;
case 2: return (T) mName;
case 3: return (T) mId;
case 4: return (T) mAnnotations;
default: return null;
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (o == null || !o.getClass().equals(getClass())) return false;
EnumValue other = (EnumValue) o;
return java.util.Objects.equals(mDocumentation, other.mDocumentation) &&
java.util.Objects.equals(mName, other.mName) &&
java.util.Objects.equals(mId, other.mId) &&
java.util.Objects.equals(mAnnotations, other.mAnnotations);
}
@Override
public int hashCode() {
if (tHashCode == 0) {
tHashCode = java.util.Objects.hash(
EnumValue.class,
_Field.DOCUMENTATION, mDocumentation,
_Field.NAME, mName,
_Field.ID, mId,
_Field.ANNOTATIONS, mAnnotations);
}
return tHashCode;
}
@Override
public String toString() {
return "p_model.EnumValue" + asString();
}
@Override
@javax.annotation.Nonnull
public String asString() {
StringBuilder out = new StringBuilder();
out.append("{");
boolean first = true;
if (hasDocumentation()) {
first = false;
out.append("documentation:")
.append('\"')
.append(net.morimekta.util.Strings.escape(mDocumentation))
.append('\"');
}
if (!first) out.append(',');
out.append("name:")
.append('\"')
.append(net.morimekta.util.Strings.escape(mName))
.append('\"');
if (hasId()) {
out.append(',');
out.append("id:")
.append(mId);
}
if (hasAnnotations()) {
out.append(',');
out.append("annotations:")
.append(net.morimekta.util.Strings.asString(mAnnotations));
}
out.append('}');
return out.toString();
}
@Override
public int compareTo(EnumValue other) {
int c;
c = Boolean.compare(mDocumentation != null, other.mDocumentation != null);
if (c != 0) return c;
if (mDocumentation != null) {
c = mDocumentation.compareTo(other.mDocumentation);
if (c != 0) return c;
}
c = mName.compareTo(other.mName);
if (c != 0) return c;
c = Boolean.compare(mId != null, other.mId != null);
if (c != 0) return c;
if (mId != null) {
c = Integer.compare(mId, other.mId);
if (c != 0) return c;
}
c = Boolean.compare(mAnnotations != null, other.mAnnotations != null);
if (c != 0) return c;
if (mAnnotations != null) {
c = Integer.compare(mAnnotations.hashCode(), other.mAnnotations.hashCode());
if (c != 0) return c;
}
return 0;
}
private void writeObject(java.io.ObjectOutputStream oos) throws java.io.IOException {
oos.defaultWriteObject();
net.morimekta.providence.serializer.BinarySerializer.INSTANCE.serialize(oos, this);
}
private void readObject(java.io.ObjectInputStream ois)
throws java.io.IOException, ClassNotFoundException {
ois.defaultReadObject();
tSerializeInstance = net.morimekta.providence.serializer.BinarySerializer.INSTANCE.deserialize(ois, kDescriptor);
}
private Object readResolve() throws java.io.ObjectStreamException {
return tSerializeInstance;
}
@Override
public int writeBinary(net.morimekta.util.io.BigEndianBinaryWriter writer) throws java.io.IOException {
int length = 0;
if (hasDocumentation()) {
length += writer.writeByte((byte) 11);
length += writer.writeShort((short) 1);
net.morimekta.util.Binary tmp_1 = net.morimekta.util.Binary.wrap(mDocumentation.getBytes(java.nio.charset.StandardCharsets.UTF_8));
length += writer.writeUInt32(tmp_1.length());
length += writer.writeBinary(tmp_1);
}
length += writer.writeByte((byte) 11);
length += writer.writeShort((short) 2);
net.morimekta.util.Binary tmp_2 = net.morimekta.util.Binary.wrap(mName.getBytes(java.nio.charset.StandardCharsets.UTF_8));
length += writer.writeUInt32(tmp_2.length());
length += writer.writeBinary(tmp_2);
if (hasId()) {
length += writer.writeByte((byte) 8);
length += writer.writeShort((short) 3);
length += writer.writeInt(mId);
}
if (hasAnnotations()) {
length += writer.writeByte((byte) 13);
length += writer.writeShort((short) 4);
length += writer.writeByte((byte) 11);
length += writer.writeByte((byte) 11);
length += writer.writeUInt32(mAnnotations.size());
for (java.util.Map.Entry entry_3 : mAnnotations.entrySet()) {
net.morimekta.util.Binary tmp_4 = net.morimekta.util.Binary.wrap(entry_3.getKey().getBytes(java.nio.charset.StandardCharsets.UTF_8));
length += writer.writeUInt32(tmp_4.length());
length += writer.writeBinary(tmp_4);
net.morimekta.util.Binary tmp_5 = net.morimekta.util.Binary.wrap(entry_3.getValue().getBytes(java.nio.charset.StandardCharsets.UTF_8));
length += writer.writeUInt32(tmp_5.length());
length += writer.writeBinary(tmp_5);
}
}
length += writer.writeByte((byte) 0);
return length;
}
@javax.annotation.Nonnull
@Override
public _Builder mutate() {
return new _Builder(this);
}
public enum _Field implements net.morimekta.providence.descriptor.PField {
DOCUMENTATION(1, net.morimekta.providence.descriptor.PRequirement.OPTIONAL, "documentation", "documentation", net.morimekta.providence.descriptor.PPrimitive.STRING.provider(), null, null),
NAME(2, net.morimekta.providence.descriptor.PRequirement.REQUIRED, "name", "name", net.morimekta.providence.descriptor.PPrimitive.STRING.provider(), null, null),
ID(3, net.morimekta.providence.descriptor.PRequirement.OPTIONAL, "id", "id", net.morimekta.providence.descriptor.PPrimitive.I32.provider(), null, null),
ANNOTATIONS(4, net.morimekta.providence.descriptor.PRequirement.OPTIONAL, "annotations", "annotations", net.morimekta.providence.descriptor.PMap.sortedProvider(net.morimekta.providence.descriptor.PPrimitive.STRING.provider(),net.morimekta.providence.descriptor.PPrimitive.STRING.provider()), null, null),
;
private final int mId;
private final net.morimekta.providence.descriptor.PRequirement mRequired;
private final String mName;
private final String mPojoName;
private final net.morimekta.providence.descriptor.PDescriptorProvider mTypeProvider;
private final net.morimekta.providence.descriptor.PStructDescriptorProvider mArgumentsProvider;
private final net.morimekta.providence.descriptor.PValueProvider> mDefaultValue;
_Field(int id, net.morimekta.providence.descriptor.PRequirement required, String name, String pojoName, net.morimekta.providence.descriptor.PDescriptorProvider typeProvider, net.morimekta.providence.descriptor.PStructDescriptorProvider argumentsProvider, net.morimekta.providence.descriptor.PValueProvider> defaultValue) {
mId = id;
mRequired = required;
mName = name;
mPojoName = pojoName;
mTypeProvider = typeProvider;
mArgumentsProvider = argumentsProvider;
mDefaultValue = defaultValue;
}
@Override
public int getId() { return mId; }
@javax.annotation.Nonnull
@Override
public net.morimekta.providence.descriptor.PRequirement getRequirement() { return mRequired; }
@javax.annotation.Nonnull
@Override
public net.morimekta.providence.descriptor.PDescriptor getDescriptor() { return mTypeProvider.descriptor(); }
@Override
@javax.annotation.Nullable
public net.morimekta.providence.descriptor.PStructDescriptor getArgumentsType() { return mArgumentsProvider == null ? null : mArgumentsProvider.descriptor(); }
@javax.annotation.Nonnull
@Override
public String getName() { return mName; }
@javax.annotation.Nonnull
@Override
public String getPojoName() { return mPojoName; }
@Override
public boolean hasDefaultValue() { return mDefaultValue != null; }
@Override
@javax.annotation.Nullable
public Object getDefaultValue() {
return hasDefaultValue() ? mDefaultValue.get() : null;
}
@Override
@javax.annotation.Nonnull
public net.morimekta.providence.descriptor.PMessageDescriptor onMessageType() {
return kDescriptor;
}
@Override
public String toString() {
return net.morimekta.providence.descriptor.PField.asString(this);
}
/**
* @param id Field ID
* @return The identified field or null
*/
public static _Field findById(int id) {
switch (id) {
case 1: return _Field.DOCUMENTATION;
case 2: return _Field.NAME;
case 3: return _Field.ID;
case 4: return _Field.ANNOTATIONS;
}
return null;
}
/**
* @param name Field name
* @return The named field or null
*/
public static _Field findByName(String name) {
if (name == null) return null;
switch (name) {
case "documentation": return _Field.DOCUMENTATION;
case "name": return _Field.NAME;
case "id": return _Field.ID;
case "annotations": return _Field.ANNOTATIONS;
}
return null;
}
/**
* @param name Field POJO name
* @return The named field or null
*/
public static _Field findByPojoName(String name) {
if (name == null) return null;
switch (name) {
case "documentation": return _Field.DOCUMENTATION;
case "name": return _Field.NAME;
case "id": return _Field.ID;
case "annotations": return _Field.ANNOTATIONS;
}
return null;
}
/**
* @param id Field ID
* @return The identified field
* @throws IllegalArgumentException If no such field
*/
public static _Field fieldForId(int id) {
_Field field = findById(id);
if (field == null) {
throw new IllegalArgumentException("No such field id " + id + " in p_model.EnumValue");
}
return field;
}
/**
* @param name Field name
* @return The named field
* @throws IllegalArgumentException If no such field
*/
public static _Field fieldForName(String name) {
if (name == null) {
throw new IllegalArgumentException("Null name argument");
}
_Field field = findByName(name);
if (field == null) {
throw new IllegalArgumentException("No such field \"" + name + "\" in p_model.EnumValue");
}
return field;
}
/**
* @param name Field POJO name
* @return The named field
* @throws IllegalArgumentException If no such field
*/
public static _Field fieldForPojoName(String name) {
if (name == null) {
throw new IllegalArgumentException("Null name argument");
}
_Field field = findByPojoName(name);
if (field == null) {
throw new IllegalArgumentException("No such field \"" + name + "\" in p_model.EnumValue");
}
return field;
}
}
@javax.annotation.Nonnull
public static net.morimekta.providence.descriptor.PStructDescriptorProvider provider() {
return new _Provider();
}
@Override
@javax.annotation.Nonnull
public net.morimekta.providence.descriptor.PStructDescriptor descriptor() {
return kDescriptor;
}
public static final net.morimekta.providence.descriptor.PStructDescriptor kDescriptor;
private static final class _Descriptor
extends net.morimekta.providence.descriptor.PStructDescriptor {
public _Descriptor() {
super("p_model", "EnumValue", _Builder::new, false);
}
@Override
@javax.annotation.Nonnull
public boolean isInnerType() {
return false;
}
@Override
@javax.annotation.Nonnull
public boolean isAutoType() {
return false;
}
@Override
@javax.annotation.Nonnull
public _Field[] getFields() {
return _Field.values();
}
@Override
@javax.annotation.Nullable
public _Field findFieldByName(String name) {
return _Field.findByName(name);
}
@Override
@javax.annotation.Nullable
public _Field findFieldByPojoName(String name) {
return _Field.findByPojoName(name);
}
@Override
@javax.annotation.Nullable
public _Field findFieldById(int id) {
return _Field.findById(id);
}
@Override
public net.morimekta.providence.descriptor.PInterfaceDescriptor getImplementing() {
return net.morimekta.providence.model.Decl.kDescriptor;
}
}
static {
kDescriptor = new _Descriptor();
}
private static final class _Provider extends net.morimekta.providence.descriptor.PStructDescriptorProvider {
@Override
public net.morimekta.providence.descriptor.PStructDescriptor descriptor() {
return kDescriptor;
}
}
/**
* Make a p_model.EnumValue
builder.
* @return The builder instance.
*/
public static _Builder builder() {
return new _Builder();
}
/**
* <name> (= <value>)
*/
public static class _Builder
extends net.morimekta.providence.PMessageBuilder
implements net.morimekta.providence.model.Decl._Builder,
EnumValue_OrBuilder,
net.morimekta.providence.serializer.binary.BinaryReader {
private java.util.BitSet optionals;
private java.util.BitSet modified;
private String mDocumentation;
private String mName;
private Integer mId;
private java.util.Map mAnnotations;
/**
* Make a p_model.EnumValue builder instance.
*/
public _Builder() {
optionals = new java.util.BitSet(4);
modified = new java.util.BitSet(4);
mName = kDefaultName;
}
/**
* Make a mutating builder off a base p_model.EnumValue.
*
* @param base The base EnumValue
*/
public _Builder(EnumValue base) {
this();
if (base.hasDocumentation()) {
optionals.set(0);
mDocumentation = base.mDocumentation;
}
optionals.set(1);
mName = base.mName;
if (base.hasId()) {
optionals.set(2);
mId = base.mId;
}
if (base.hasAnnotations()) {
optionals.set(3);
mAnnotations = base.mAnnotations;
}
}
@javax.annotation.Nonnull
@Override
public EnumValue._Builder merge(EnumValue from) {
if (from.hasDocumentation()) {
optionals.set(0);
modified.set(0);
mDocumentation = from.getDocumentation();
}
optionals.set(1);
modified.set(1);
mName = from.getName();
if (from.hasId()) {
optionals.set(2);
modified.set(2);
mId = from.getId();
}
if (from.hasAnnotations()) {
optionals.set(3);
modified.set(3);
mutableAnnotations().putAll(from.getAnnotations());
}
return this;
}
/**
* Set the documentation
field value.
*
* @param value The new value
* @return The builder
*/
@javax.annotation.Nonnull
public EnumValue._Builder setDocumentation(String value) {
if (value == null) {
return clearDocumentation();
}
optionals.set(0);
modified.set(0);
mDocumentation = value;
return this;
}
/**
* Checks for explicit presence of the documentation
field.
*
* @return True if documentation has been set.
*/
public boolean isSetDocumentation() {
return optionals.get(0);
}
/**
* Checks for presence of the documentation
field.
*
* @return True if documentation is present.
*/
public boolean hasDocumentation() {
return optionals.get(0);
}
/**
* Checks if the documentation
field has been modified since the
* builder was created.
*
* @return True if documentation has been modified.
*/
public boolean isModifiedDocumentation() {
return modified.get(0);
}
/**
* Clear the documentation
field.
*
* @return The builder
*/
@javax.annotation.Nonnull
public EnumValue._Builder clearDocumentation() {
optionals.clear(0);
modified.set(0);
mDocumentation = null;
return this;
}
/**
* @return The documentation
field value
*/
public String getDocumentation() {
return mDocumentation;
}
/**
* @return Optional documentation
field value
*/
@javax.annotation.Nonnull
public java.util.Optional optionalDocumentation() {
return java.util.Optional.ofNullable(mDocumentation);
}
/**
* Set the name
field value.
*
* @param value The new value
* @return The builder
*/
@javax.annotation.Nonnull
public EnumValue._Builder setName(String value) {
if (value == null) {
return clearName();
}
optionals.set(1);
modified.set(1);
mName = value;
return this;
}
/**
* Checks for explicit presence of the name
field.
*
* @return True if name has been set.
*/
public boolean isSetName() {
return optionals.get(1);
}
/**
* Checks for presence of the name
field.
*
* @return True if name is present.
*/
public boolean hasName() {
return true;
}
/**
* Checks if the name
field has been modified since the
* builder was created.
*
* @return True if name has been modified.
*/
public boolean isModifiedName() {
return modified.get(1);
}
/**
* Clear the name
field.
*
* @return The builder
*/
@javax.annotation.Nonnull
public EnumValue._Builder clearName() {
optionals.clear(1);
modified.set(1);
mName = kDefaultName;
return this;
}
/**
* @return The name
field value
*/
public String getName() {
return isSetName() ? mName : kDefaultName;
}
/**
* Set the id
field value.
*
* @param value The new value
* @return The builder
*/
@javax.annotation.Nonnull
public EnumValue._Builder setId(Integer value) {
if (value == null) {
return clearId();
}
optionals.set(2);
modified.set(2);
mId = value;
return this;
}
/**
* Set the id
field value.
*
* @param value The new value
* @return The builder
*/
@javax.annotation.Nonnull
public EnumValue._Builder setId(int value) {
optionals.set(2);
modified.set(2);
mId = value;
return this;
}
/**
* Checks for explicit presence of the id
field.
*
* @return True if id has been set.
*/
public boolean isSetId() {
return optionals.get(2);
}
/**
* Checks for presence of the id
field.
*
* @return True if id is present.
*/
public boolean hasId() {
return optionals.get(2);
}
/**
* Checks if the id
field has been modified since the
* builder was created.
*
* @return True if id has been modified.
*/
public boolean isModifiedId() {
return modified.get(2);
}
/**
* Clear the id
field.
*
* @return The builder
*/
@javax.annotation.Nonnull
public EnumValue._Builder clearId() {
optionals.clear(2);
modified.set(2);
mId = null;
return this;
}
/**
* @return The id
field value
*/
public int getId() {
return isSetId() ? mId : kDefaultId;
}
/**
* @return Optional id
field value
*/
@javax.annotation.Nonnull
public java.util.Optional optionalId() {
return java.util.Optional.ofNullable(mId);
}
/**
* Set the annotations
field value.
*
* @param value The new value
* @return The builder
*/
@javax.annotation.Nonnull
public EnumValue._Builder setAnnotations(java.util.Map value) {
if (value == null) {
return clearAnnotations();
}
optionals.set(3);
modified.set(3);
mAnnotations = net.morimekta.util.collect.UnmodifiableSortedMap.copyOf(value);
return this;
}
/**
* Adds a mapping to the annotations
map.
*
* @param key The inserted key
* @param value The inserted value
* @return The builder
*/
@javax.annotation.Nonnull
public EnumValue._Builder putInAnnotations(String key, String value) {
optionals.set(3);
modified.set(3);
mutableAnnotations().put(key, value);
return this;
}
/**
* Checks for explicit presence of the annotations
field.
*
* @return True if annotations has been set.
*/
public boolean isSetAnnotations() {
return optionals.get(3);
}
/**
* Checks for presence of the annotations
field.
*
* @return True if annotations is present.
*/
public boolean hasAnnotations() {
return optionals.get(3);
}
/**
* Checks if the annotations
field has been modified since the
* builder was created.
*
* @return True if annotations has been modified.
*/
public boolean isModifiedAnnotations() {
return modified.get(3);
}
/**
* Clear the annotations
field.
*
* @return The builder
*/
@javax.annotation.Nonnull
public EnumValue._Builder clearAnnotations() {
optionals.clear(3);
modified.set(3);
mAnnotations = null;
return this;
}
/**
* @return The mutable annotations
container
*/
public java.util.Map mutableAnnotations() {
optionals.set(3);
modified.set(3);
if (mAnnotations == null) {
mAnnotations = new java.util.TreeMap<>();
} else if (!(mAnnotations instanceof java.util.TreeMap)) {
mAnnotations = new java.util.TreeMap<>(mAnnotations);
}
return mAnnotations;
}
/**
* @return The annotations
field value
*/
public java.util.Map getAnnotations() {
return mAnnotations;
}
/**
* @return Optional annotations
field value
*/
@javax.annotation.Nonnull
public java.util.Optional> optionalAnnotations() {
return java.util.Optional.ofNullable(mAnnotations);
}
/**
* @return Number of entries in annotations
.
*/
public int numAnnotations() {
return mAnnotations != null ? mAnnotations.size() : 0;
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (o == null || !o.getClass().equals(getClass())) return false;
EnumValue._Builder other = (EnumValue._Builder) o;
return java.util.Objects.equals(optionals, other.optionals) &&
java.util.Objects.equals(mDocumentation, other.mDocumentation) &&
java.util.Objects.equals(mName, other.mName) &&
java.util.Objects.equals(mId, other.mId) &&
java.util.Objects.equals(mAnnotations, other.mAnnotations);
}
@Override
public int hashCode() {
return java.util.Objects.hash(
EnumValue.class, optionals,
EnumValue._Field.DOCUMENTATION, mDocumentation,
EnumValue._Field.NAME, mName,
EnumValue._Field.ID, mId,
EnumValue._Field.ANNOTATIONS, mAnnotations);
}
@Override
@SuppressWarnings("unchecked")
public net.morimekta.providence.PMessageBuilder mutator(int key) {
switch (key) {
default: throw new IllegalArgumentException("Not a message field ID: " + key);
}
}
@javax.annotation.Nonnull
@Override
@SuppressWarnings("unchecked")
public EnumValue._Builder set(int key, Object value) {
if (value == null) return clear(key);
switch (key) {
case 1: setDocumentation((String) value); break;
case 2: setName((String) value); break;
case 3: setId((int) value); break;
case 4: setAnnotations((java.util.Map) value); break;
default: break;
}
return this;
}
@Override
public boolean isSet(int key) {
switch (key) {
case 1: return optionals.get(0);
case 2: return optionals.get(1);
case 3: return optionals.get(2);
case 4: return optionals.get(3);
default: break;
}
return false;
}
@Override
public boolean isModified(int key) {
switch (key) {
case 1: return modified.get(0);
case 2: return modified.get(1);
case 3: return modified.get(2);
case 4: return modified.get(3);
default: break;
}
return false;
}
@Override
@SuppressWarnings("unchecked")
public T get(int key) {
switch(key) {
case 1: return (T) getDocumentation();
case 2: return (T) getName();
case 3: return (T) (Object) getId();
case 4: return (T) getAnnotations();
default: return null;
}
}
@Override
public boolean has(int key) {
switch(key) {
case 1: return mDocumentation != null;
case 2: return true;
case 3: return mId != null;
case 4: return mAnnotations != null;
default: return false;
}
}
@javax.annotation.Nonnull
@Override
@SuppressWarnings("unchecked")
public EnumValue._Builder addTo(int key, Object value) {
switch (key) {
default: break;
}
return this;
}
@javax.annotation.Nonnull
@Override
public EnumValue._Builder clear(int key) {
switch (key) {
case 1: clearDocumentation(); break;
case 2: clearName(); break;
case 3: clearId(); break;
case 4: clearAnnotations(); break;
default: break;
}
return this;
}
@Override
public boolean valid() {
return optionals.get(1);
}
@Override
public EnumValue._Builder validate() {
if (!valid()) {
java.util.ArrayList missing = new java.util.ArrayList<>();
if (!optionals.get(1)) {
missing.add("name");
}
throw new java.lang.IllegalStateException(
"Missing required fields " +
String.join(",", missing) +
" in message p_model.EnumValue");
}
return this;
}
@javax.annotation.Nonnull
@Override
public net.morimekta.providence.descriptor.PStructDescriptor descriptor() {
return EnumValue.kDescriptor;
}
@Override
public void readBinary(net.morimekta.util.io.BigEndianBinaryReader reader, boolean strict) throws java.io.IOException {
byte type = reader.expectByte();
while (type != 0) {
int field = reader.expectShort();
switch (field) {
case 1: {
if (type == 11) {
int len_1 = reader.expectUInt32();
mDocumentation = new String(reader.expectBytes(len_1), java.nio.charset.StandardCharsets.UTF_8);
optionals.set(0);
} else {
throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for p_model.EnumValue.documentation, should be struct(12)");
}
break;
}
case 2: {
if (type == 11) {
int len_2 = reader.expectUInt32();
mName = new String(reader.expectBytes(len_2), java.nio.charset.StandardCharsets.UTF_8);
optionals.set(1);
} else {
throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for p_model.EnumValue.name, should be struct(12)");
}
break;
}
case 3: {
if (type == 8) {
mId = reader.expectInt();
optionals.set(2);
} else {
throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for p_model.EnumValue.id, should be struct(12)");
}
break;
}
case 4: {
if (type == 13) {
byte t_5 = reader.expectByte();
byte t_6 = reader.expectByte();
if (t_5 == 11 && t_6 == 11) {
final int len_4 = reader.expectUInt32();
net.morimekta.util.collect.UnmodifiableSortedMap.Builder b_3 = net.morimekta.util.collect.UnmodifiableSortedMap.builderNaturalOrder(len_4);
for (int i_7 = 0; i_7 < len_4; ++i_7) {
int len_10 = reader.expectUInt32();
String key_8 = new String(reader.expectBytes(len_10), java.nio.charset.StandardCharsets.UTF_8);
int len_11 = reader.expectUInt32();
String val_9 = new String(reader.expectBytes(len_11), java.nio.charset.StandardCharsets.UTF_8);
b_3.put(key_8, val_9);
}
mAnnotations = b_3.build();
} else {
throw new net.morimekta.providence.serializer.SerializerException(
"Wrong key type " + net.morimekta.providence.serializer.binary.BinaryType.asString(t_5) +
" or value type " + net.morimekta.providence.serializer.binary.BinaryType.asString(t_6) +
" for p_model.EnumValue.annotations, should be string(11) and string(11)");
}
optionals.set(3);
} else {
throw new net.morimekta.providence.serializer.SerializerException("Wrong type " + net.morimekta.providence.serializer.binary.BinaryType.asString(type) + " for p_model.EnumValue.annotations, should be struct(12)");
}
break;
}
default: {
net.morimekta.providence.serializer.binary.BinaryFormatUtils.readFieldValue(reader, new net.morimekta.providence.serializer.binary.BinaryFormatUtils.FieldInfo(field, type), null, false);
break;
}
}
type = reader.expectByte();
}
}
@Override
@javax.annotation.Nonnull
public EnumValue build() {
return new EnumValue(this);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy