AbstractThriftMetadataBuilder.java 文件源码

java
阅读 38 收藏 0 点赞 0 评论 0

项目:drift 作者:
/**
 * 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, FieldMetadata::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, FieldMetadata::extractName);
    inferThriftFieldIds(fieldsByExtractedName, fieldsWithConflictingIds);

    return fieldsWithConflictingIds;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号