Type mapKeyType = getMapKeyType(javaType); Type mapValueType = getMapValueType(javaType); return isSupportedStructFieldType(mapKeyType) && isSupportedStructFieldType(mapValueType); return isSupportedStructFieldType(elementType); return isSupportedStructFieldType(elementType);
Type mapKeyType = getMapKeyType(javaType); Type mapValueType = getMapValueType(javaType); if (isSupportedStructFieldType(mapKeyType) && isSupportedStructFieldType(mapValueType)) { return ThriftProtocolType.MAP; if (isSupportedStructFieldType(elementType)) { return ThriftProtocolType.SET; if (isSupportedStructFieldType(elementType)) { return ThriftProtocolType.LIST;
/** * Verifies that the the fields all have a supported Java type and that all fields map to the * exact same ThriftType. */ protected final void verifyFieldType(short id, String name, Collection<FieldMetadata> fields, ThriftCatalog catalog) { boolean isSupportedType = true; for (FieldMetadata field : fields) { if (!catalog.isSupportedStructFieldType(field.getJavaType())) { metadataErrors.addError("Thrift class '%s' field '%s(%s)' type '%s' is not a supported Java type", structName, name, id, TypeToken.of(field.getJavaType())); isSupportedType = false; // only report the error once break; } } // fields must have the same type if (isSupportedType) { Set<ThriftTypeReference> types = new HashSet<>(); for (FieldMetadata field : fields) { types.add(catalog.getFieldThriftTypeReference(field)); } if (types.size() > 1) { metadataErrors.addError("Thrift class '%s' field '%s(%s)' has multiple types: %s", structName, name, id, types); } } }
/** * Verifies that the the fields all have a supported Java type and that all fields map to the * exact same ThriftType. */ protected final void verifyFieldType(short id, String name, Collection<FieldMetadata> fields, ThriftCatalog catalog) { boolean isSupportedType = true; for (FieldMetadata field : fields) { if (!catalog.isSupportedStructFieldType(field.getJavaType())) { metadataErrors.addError("Thrift class '%s' field '%s(%s)' type '%s' is not a supported Java type", structName, name, id, TypeToken.of(field.getJavaType())); isSupportedType = false; // only report the error once break; } } // fields must have the same type if (isSupportedType) { Set<ThriftType> types = new HashSet<>(); for (FieldMetadata field : fields) { types.add(catalog.getThriftType(field.getJavaType())); } if (types.size() > 1) { metadataErrors.addError("Thrift class '%s' field '%s(%s)' has multiple types: %s", structName, name, id, types); } } }