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; }
/** * Assigns all fields an id if possible. Fields are grouped by name and for each group, if there * is a single id, all fields in the group are assigned this id. If the group has multiple ids, * an error is reported. */ protected final Set<String> inferThriftFieldIds() { Set<String> fieldsWithConflictingIds = new HashSet<>(); // group fields by explicit name or by name extracted from field, method or property Multimap<String, FieldMetadata> fieldsByExplicitOrExtractedName = Multimaps.index(fields, getOrExtractThriftFieldName()); inferThriftFieldIds(fieldsByExplicitOrExtractedName, fieldsWithConflictingIds); // group fields by name extracted from field, method or property // this allows thrift name to be set explicitly without having to duplicate the name on getters and setters // todo should this be the only way this works? Multimap<String, FieldMetadata> fieldsByExtractedName = Multimaps.index(fields, extractThriftFieldName()); inferThriftFieldIds(fieldsByExtractedName, fieldsWithConflictingIds); return fieldsWithConflictingIds; }
/** * Assigns all fields an id if possible. Fields are grouped by name and for each group, if there * is a single id, all fields in the group are assigned this id. If the group has multiple ids, * an error is reported. */ protected final Set<String> inferThriftFieldIds() { Set<String> fieldsWithConflictingIds = new HashSet<>(); // group fields by explicit name or by name extracted from field, method or property Multimap<String, FieldMetadata> fieldsByExplicitOrExtractedName = Multimaps.index(fields, getOrExtractThriftFieldName()); inferThriftFieldIds(fieldsByExplicitOrExtractedName, fieldsWithConflictingIds); // group fields by name extracted from field, method or property // this allows thrift name to be set explicitly without having to duplicate the name on getters and setters // todo should this be the only way this works? Multimap<String, FieldMetadata> fieldsByExtractedName = Multimaps.index(fields, extractThriftFieldName()); inferThriftFieldIds(fieldsByExtractedName, fieldsWithConflictingIds); return fieldsWithConflictingIds; }