IdentifierTransformer { public static Object transformToIdentifier(Object value, Class<?> targetType) { if (!isValidIdentifierType(targetType)) { throw new IllegalArgumentException( "The specified value " + value + " cannot be transformed to target type " + targetType); } return TRANSFORMERS.get(targetType).apply(value); } private  IdentifierTransformer(); static Object transformToIdentifier(Object value, Class<?> targetType); static URI valueAsUri(Object value); static boolean isValidIdentifierType(Class<?> type);  }
@Test void transformUriToUri() { final Object res = IdentifierTransformer.transformToIdentifier(IDENTIFIER, URI.class); assertTrue(res instanceof URI); assertEquals(STR_IDENTIFIER, res.toString()); }
@Test void transformUriToString() { final Object res = IdentifierTransformer.transformToIdentifier(IDENTIFIER, String.class); assertTrue(res instanceof String); assertEquals(STR_IDENTIFIER, res); }
@Test void transformUriToUrl() { final Object res = IdentifierTransformer.transformToIdentifier(IDENTIFIER, URL.class); assertTrue(res instanceof URL); assertEquals(STR_IDENTIFIER, res.toString()); }
@Test void transformThrowsIllegalArgumentForUnsupportedTargetType() { assertThrows(IllegalArgumentException.class, () -> IdentifierTransformer.transformToIdentifier(IDENTIFIER, Date.class)); }