ModelDescription.java 文件源码

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

项目:MCAnm 作者:
private ImmutableMap<TransformType, TRSRTransformation> parseTransformObject(
        JsonDeserializationContext context,
        JsonObject viewObject) {
    ListMultimap<String, JsonElement> transformEntries = MultimapBuilder.hashKeys().arrayListValues(1).build();
    for (Map.Entry<String, JsonElement> entry : viewObject.entrySet()) {
        transformEntries.put(entry.getKey().toUpperCase(Locale.ROOT), entry.getValue());
    }

    ImmutableMap.Builder<TransformType, TRSRTransformation> result = ImmutableMap.builder();
    for (TransformType transformType : TransformType.values()) {
        String transformName = transformType.name().toUpperCase(Locale.ROOT);
        List<JsonElement> entryList = transformEntries.get(transformName);
        if (entryList.isEmpty()) {
            continue;
        }
        if (entryList.size() > 1) {
            throw new JsonParseException("Two transform entries for " + transformName);
        }
        JsonElement onlyElement = entryList.get(0);
        result.put(transformType, context.deserialize(onlyElement, TRSRTransformation.class));
    }
    return result.build();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号