@VisibleForTesting EnumInfo newEnumInfo(EnumDescriptor enumDescriptor) { return new EnumInfo( enumDescriptor.getFullName(), enumDescriptor.getValues().stream() .map(d -> new EnumValueInfo(d.getName())) .collect(toImmutableList())); }
if (value == null) { throw tokenizer.parseExceptionPreviousToken( "Enum type \"" + enumType.getFullName() + "\" has no value with number " + number + '.'); if (value == null) { throw tokenizer.parseExceptionPreviousToken( "Enum type \"" + enumType.getFullName() + "\" has no value named \"" + id + "\".");
case ENUM: fieldType = TypeSignature.ofNamed( fieldDescriptor.getEnumType().getFullName(), fieldDescriptor.getEnumType()); break; default:
private EnumValueDescriptor(final EnumValueDescriptorProto proto, final FileDescriptor file, final EnumDescriptor parent, final int index) throws DescriptorValidationException { this.index = index; this.proto = proto; this.file = file; type = parent; fullName = parent.getFullName() + '.' + proto.getName(); file.pool.addSymbol(this); file.pool.addEnumValueByNumber(this); }
private EnumValueDescriptor(final EnumValueDescriptorProto proto, final FileDescriptor file, final EnumDescriptor parent, final int index) throws DescriptorValidationException { this.index = index; this.proto = proto; this.file = file; type = parent; fullName = parent.getFullName() + '.' + proto.getName(); file.pool.addSymbol(this); file.pool.addEnumValueByNumber(this); }
public ProtoFieldRowMapper(IFieldResolver fieldResolver, FieldDescriptor fd) { if (fd.isRepeated()) { throw new UnsupportedOperationException( "not supported for repeated field, field=" + fd.getFullName()); } if (fd.getJavaType().equals(FieldDescriptor.JavaType.ENUM)) { throw new UnsupportedOperationException( "not supported for enum field, field=" + fd.getFullName() + ", enumType=" + fd.getEnumType().getFullName()); } this.fieldResolver = fieldResolver; this.fd = fd; }
@Override protected SoyType visitEnum(EnumDescriptor enumType) { return registry.getType(enumType.getFullName()); }
/** * Creates additional Enums (NullValue) to be added to the Service config. */ // TODO (guptasu): Fix this hack. Find a better way to add the predefined types. // TODO (guptasu): Add them only when required and not in all cases. static Iterable<Enum> createAdditionalServiceEnums() { // TODO (guptasu): Remove this hard coding. Without this, creation of Model from Service throws. // Needs investigation. String fileName = "struct.proto"; List<Enum> additionalEnums = Lists.newArrayList(); additionalEnums.add(TypesBuilderFromDescriptor.createEnum(NullValue.getDescriptor().getFullName(), NullValue.getDescriptor().toProto(), fileName)); return additionalEnums; }
public String getName() { return descriptor.getFullName(); }
@VisibleForTesting EnumInfo newEnumInfo(EnumDescriptor enumDescriptor) { return new EnumInfo( enumDescriptor.getFullName(), enumDescriptor.getValues().stream() .map(d -> new EnumValueInfo(d.getName())) .collect(toImmutableList())); }
public String getName() { return descriptor.getFullName(); }
@Override public String toString(T enumValue) { if (enumValue == null) { return String.format("%s{null}", descriptor.getFullName()); } if (this.unrecognized.equals(enumValue)) { return String.format("%s{UNRECOGNIZED[-1]}", descriptor.getFullName()); } return String .format("%s{%s[%d]}", descriptor.getFullName(), enumValue.getValueDescriptor().getName(), enumValue.getNumber()); } }
private void addEnumType(EnumDescriptor enumType, String scope, Set<String> enumDupes) { String enumTypeNameFull = enumType.getFullName(); String enumTypeNameShort = (scope == null ? enumType.getName() : scope + "." + enumType.getName()); if (mEnumDescriptorMapFull.containsKey(enumTypeNameFull)) throw new IllegalArgumentException("duplicate name: " + enumTypeNameFull); if (mEnumDescriptorMapShort.containsKey(enumTypeNameShort)) enumDupes.add(enumTypeNameShort); mEnumDescriptorMapFull.put(enumTypeNameFull, enumType); mEnumDescriptorMapShort.put(enumTypeNameShort, enumType); }
private static EnumValueDescriptor toEnumValueDescriptor(FieldDescriptor fieldDescriptor, String name) { EnumValueDescriptor out = fieldDescriptor.getEnumType().findValueByName(name); if (out == null) { throw new IllegalArgumentException( String.format("Failed to convert string '%s'" + " to enum value of type '%s'", name, fieldDescriptor.getEnumType().getFullName())); } return out; }
@Override protected SoyType visitEnum(EnumDescriptor enumType) { return registry.getType(enumType.getFullName()); }
if (value == null) { throw tokenizer.parseExceptionPreviousToken("Enum type \"" + enumType.getFullName() + "\" has no value with number " + number + ""); if (value == null) { throw tokenizer.parseExceptionPreviousToken("Enum type \"" + enumType.getFullName() + "\" has no value named \"" + id + "\".");
String unknownValueMsg = "Enum type \"" + enumType.getFullName() + "\" has no value with number " + number throw tokenizer.parseExceptionPreviousToken( "Enum type \"" + enumType.getFullName() + "\" has no value with number " + number String unknownValueMsg = "Enum type \"" + enumType.getFullName() + "\" has no value named \"" + id
private EnumValueDescriptor( final FileDescriptor file, final EnumDescriptor parent, final Integer number) { String name = "UNKNOWN_ENUM_VALUE_" + parent.getName() + "_" + number; EnumValueDescriptorProto proto = EnumValueDescriptorProto .newBuilder().setName(name).setNumber(number).build(); this.index = -1; this.proto = proto; this.file = file; this.type = parent; this.fullName = parent.getFullName() + '.' + proto.getName(); this.number = number; // Don't add this descriptor into pool. }
private EnumValueDescriptor(final EnumValueDescriptorProto proto, final FileDescriptor file, final EnumDescriptor parent, final int index) throws DescriptorValidationException { this.index = index; this.proto = proto; this.file = file; type = parent; fullName = parent.getFullName() + '.' + proto.getName(); file.pool.addSymbol(this); file.pool.addEnumValueByNumber(this); }
private EnumValueDescriptor(final EnumValueDescriptorProto proto, final FileDescriptor file, final EnumDescriptor parent, final int index) throws DescriptorValidationException { this.index = index; this.proto = proto; this.file = file; type = parent; fullName = parent.getFullName() + '.' + proto.getName(); file.pool.addSymbol(this); file.pool.addEnumValueByNumber(this); }