private String expectedCollectionClassName(HollowSchema referencedSchema) { if (referencedSchema instanceof HollowObjectSchema) { return referencedSchema.getName(); } else if (referencedSchema instanceof HollowListSchema) { importClasses.add(List.class); HollowSchema elementSchema = dataset.getSchema(((HollowListSchema)referencedSchema).getElementType()); return "ListOf" + expectedCollectionClassName(elementSchema); } else if (referencedSchema instanceof HollowSetSchema) { importClasses.add(Set.class); HollowSchema elementSchema = dataset.getSchema(((HollowSetSchema)referencedSchema).getElementType()); return "SetOf" + expectedCollectionClassName(elementSchema); } else if (referencedSchema instanceof HollowMapSchema) { importClasses.add(Map.class); HollowSchema keySchema = dataset.getSchema(((HollowMapSchema)referencedSchema).getKeyType()); HollowSchema valueSchema = dataset.getSchema(((HollowMapSchema)referencedSchema).getValueType()); return "MapOf" + expectedCollectionClassName(keySchema) + "To" + expectedCollectionClassName(valueSchema); } throw new IllegalArgumentException("Expected HollowCollectionSchema or HollowMapSchema but got " + referencedSchema.getClass().getSimpleName()); }
private boolean fieldNeedsTypeNameAnnotation(int i) { if (schema.getFieldType(i) == FieldType.REFERENCE) { HollowSchema referencedSchema = dataset.getSchema(schema.getReferencedType(i)); return !referencedSchema.getName().equals(expectedCollectionClassName(referencedSchema)); } return false; }