All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.morimekta.providence.model.MessageVariant Maven / Gradle / Ivy

package net.morimekta.providence.model;

/**
 * Struct variant for StructType. The lower-case of the enum value is the
 * thrift keyword.
 * 

* STRUCT: Normal Structure. * UNION: Only one field set to be valid. * EXCEPTION: Handled as exception (Java, Python etc.). *

* Providence Only: *

* INTERFACE: Not a real type. Only interface. Struct can 'implement' this * And will then require to have matching fields. Field ids not * allowed. */ @javax.annotation.Generated( value = "net.morimekta.providence:providence-generator-java", comments = "java:serializable") public enum MessageVariant implements net.morimekta.providence.PEnumValue { STRUCT(1, "STRUCT"), UNION(2, "UNION"), EXCEPTION(3, "EXCEPTION"), INTERFACE(4, "INTERFACE"), ; private final int mId; private final String mName; MessageVariant(int id, String name) { mId = id; mName = name; } @Override public int asInteger() { return mId; } @Override @javax.annotation.Nonnull public String asString() { return mName; } /** * Find a value based in its ID * * @param id Id of value * @return Value found or null */ @javax.annotation.Nullable public static MessageVariant findById(Integer id) { if (id == null) { return null; } switch (id) { case 1: return MessageVariant.STRUCT; case 2: return MessageVariant.UNION; case 3: return MessageVariant.EXCEPTION; case 4: return MessageVariant.INTERFACE; default: return null; } } /** * Find a value based in its name * * @param name Name of value * @return Value found or null */ @javax.annotation.Nullable public static MessageVariant findByName(String name) { if (name == null) { return null; } switch (name) { case "STRUCT": return MessageVariant.STRUCT; case "UNION": return MessageVariant.UNION; case "EXCEPTION": return MessageVariant.EXCEPTION; case "INTERFACE": return MessageVariant.INTERFACE; default: return null; } } /** * Get a value based in its ID * * @param id Id of value * @return Value found * @throws IllegalArgumentException If no value for id is found */ @javax.annotation.Nonnull public static MessageVariant valueForId(int id) { MessageVariant value = findById(id); if (value == null) { throw new IllegalArgumentException("No p_model.MessageVariant for id " + id); } return value; } /** * Get a value based in its name * * @param name Name of value * @return Value found * @throws IllegalArgumentException If no value for name is found, or null name */ @javax.annotation.Nonnull public static MessageVariant valueForName(@javax.annotation.Nonnull String name) { MessageVariant value = findByName(name); if (value == null) { throw new IllegalArgumentException("No p_model.MessageVariant for name \"" + name + "\""); } return value; } public static final class _Builder extends net.morimekta.providence.PEnumBuilder { private MessageVariant mValue; @Override @javax.annotation.Nonnull public _Builder setById(int value) { mValue = MessageVariant.findById(value); return this; } @Override @javax.annotation.Nonnull public _Builder setByName(String name) { mValue = MessageVariant.findByName(name); return this; } @Override public boolean valid() { return mValue != null; } @Override public MessageVariant build() { return mValue; } } public static final net.morimekta.providence.descriptor.PEnumDescriptor kDescriptor; @Override public net.morimekta.providence.descriptor.PEnumDescriptor descriptor() { return kDescriptor; } public static net.morimekta.providence.descriptor.PEnumDescriptorProvider provider() { return new net.morimekta.providence.descriptor.PEnumDescriptorProvider(kDescriptor); } private static final class _Descriptor extends net.morimekta.providence.descriptor.PEnumDescriptor { public _Descriptor() { super("p_model", "MessageVariant", _Builder::new); } @Override @javax.annotation.Nonnull public boolean isInnerType() { return false; } @Override @javax.annotation.Nonnull public boolean isAutoType() { return false; } @Override @javax.annotation.Nonnull public MessageVariant[] getValues() { return MessageVariant.values(); } @Override @javax.annotation.Nullable public MessageVariant findById(int id) { return MessageVariant.findById(id); } @Override @javax.annotation.Nullable public MessageVariant findByName(String name) { return MessageVariant.findByName(name); } } static { kDescriptor = new _Descriptor(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy