use of org.infinispan.protostream.descriptors.EnumValueDescriptor in project protostream by infinispan.
the class ImportedProtoTypeMetadata method getEnumMemberByName.
@Override
public ProtoEnumValueMetadata getEnumMemberByName(String name) {
if (!isEnum()) {
throw new IllegalStateException(getFullName() + " is not an enum");
}
EnumValueDescriptor evd = ((EnumDescriptor) descriptor).findValueByName(name);
if (evd == null) {
return null;
}
Enum<?> enumConstant = ((EnumMarshaller) marshaller).decode(evd.getNumber());
return new ProtoEnumValueMetadata(evd.getNumber(), name, enumConstant.ordinal(), enumConstant.getDeclaringClass().getCanonicalName() + '.' + enumConstant.name(), null);
}
Aggregations