FieldMappingValidator { void validateTypesField(Field field) { if (!Set.class.isAssignableFrom(field.getType())) { throw new InvalidFieldMappingException("Expected @Types field to be a set, but it is a " + field.getType()); } if (isRawType(field.getGenericType())) { throw new InvalidFieldMappingException("@Types field cannot be a raw set."); } final ParameterizedType typeSpec = (ParameterizedType) field.getGenericType(); if (!isValidIdentifierType(typeSpec.getActualTypeArguments()[0])) { throw new InvalidFieldMappingException( "@Types field value is not a valid identifier type. Expected one of " + SUPPORTED_IDENTIFIER_TYPES); } }    }
@Test void nonSetTypesFieldThrowsException() { assertThrows(InvalidFieldMappingException.class, () -> validator.validateTypesField(getField("typesList"))); }
@Test void rawTypesSetThrowsException() { assertThrows(InvalidFieldMappingException.class, () -> validator.validateTypesField(getField("rawTypes"))); }
@Test void invalidTypesValueTypeThrowsException() { assertThrows(InvalidFieldMappingException.class, () -> validator.validateTypesField(getField("invalidValueTypes"))); }
@Test void setOfUrisIsValidTypesField() throws Exception { validator.validateTypesField(getField("validTypes")); }