protected final String extractFieldName(short id, Collection<FieldMetadata> fields) { // get the names used by these fields Set<String> names = ImmutableSet.copyOf(filter(transform(fields, getThriftFieldName()), notNull())); String name; if (!names.isEmpty()) { if (names.size() > 1) { metadataErrors.addWarning("Thrift class %s field %s has multiple names %s", structName, id, names); } name = names.iterator().next(); } else { // pick a name for this field name = Iterables.find(transform(fields, extractThriftFieldName()), notNull()); } return name; }
protected final String extractFieldName(short id, Collection<FieldMetadata> fields) { // get the names used by these fields Set<String> names = ImmutableSet.copyOf(filter(transform(fields, getThriftFieldName()), notNull())); String name; if (!names.isEmpty()) { if (names.size() > 1) { metadataErrors.addWarning("Thrift class %s field %s has multiple names %s", structName, id, names); } name = names.iterator().next(); } else { // pick a name for this field name = Iterables.find(transform(fields, extractThriftFieldName()), notNull()); } return name; }
protected final void extractFromConstructors() { if (builderType == null) { // struct class must have a valid constructor addConstructors(structType); } else { // builder class must have a valid constructor addConstructors(builderType); // builder class must have a build method annotated with @ThriftConstructor addBuilderMethods(); // verify struct class does not have @ThriftConstructors for (Constructor<?> constructor : getStructClass().getConstructors()) { if (constructor.isAnnotationPresent(ThriftConstructor.class)) { metadataErrors.addWarning("Thrift class '%s' has a builder class, but constructor '%s' annotated with @ThriftConstructor", getStructClass().getName(), constructor); } } } }
protected final void extractFromConstructors() { if (builderType == null) { // struct class must have a valid constructor addConstructors(structType); } else { // builder class must have a valid constructor addConstructors(builderType); // builder class must have a build method annotated with @ThriftConstructor addBuilderMethods(); // verify struct class does not have @ThriftConstructors for (Constructor<?> constructor : getStructClass().getConstructors()) { if (constructor.isAnnotationPresent(ThriftConstructor.class)) { metadataErrors.addWarning("Thrift class '%s' has a builder class, but constructor '%s' annotated with @ThriftConstructor", getStructClass().getName(), constructor); } } } }