List of usage examples for org.apache.commons.lang3.reflect Typed getType
Type getType();
From source file:QuickTest.java
@Test public void testTyped() { final Typed stringList = new TypeLiteral<List<String>>() { };/*from w w w .j a v a2s .c om*/ final Typed stringArrayList = new TypeLiteral<ArrayList<String>>() { }; log.info(String.format("stringList : %s", stringList)); log.info(String.format("stringList.getType() : %s", stringList.getType())); assertThat(TypeUtils.isAssignable(stringArrayList.getType(), stringList.getType()), is(true)); assertThat(TypeUtils.isAssignable(stringList.getType(), stringArrayList.getType()), is(false)); assertThat(TypeUtils.isAssignable(stringList.getType(), stringArrayList.getType()), is(false)); }
From source file:therian.operator.convert.AssignableElementConverter.java
protected Type sourceComponentType(Typed<?> item) { final Type t = item.getType(); final Class<?> varOwner = sourceElementType.getGenericDeclaration(); final Map<TypeVariable<?>, Type> args = TypeUtils.getTypeArguments(t, varOwner); return args == null ? null : ObjectUtils.defaultIfNull(TypeUtils.unrollVariables(args, sourceElementType), Object.class); }
From source file:therian.operator.convert.AssignableElementConverter.java
protected Type targetComponentType(Typed<?> item) { final Type t = item.getType(); final Class<?> varOwner = targetElementType.getGenericDeclaration(); if (t instanceof Class<?>) { // raw// w w w .j a v a 2 s. c om return Object.class; } if (TypeUtils.isAssignable(t, varOwner)) { return TypeUtils.unrollVariables(TypeUtils.getTypeArguments(t, varOwner), targetElementType); } if (t instanceof ParameterizedType) { final Map<TypeVariable<?>, Type> args = TypeUtils.determineTypeArguments(varOwner, (ParameterizedType) t); return args.get(targetElementType); } return null; }
From source file:therian.util.Positions.java
/** * Get a read-write position of type {@code type#value}. * * @param typed not {@code null}/*from w w w.j a v a2 s. c om*/ * @return Position.ReadWrite */ public static <T> Position.ReadWrite<T> readWrite(final Typed<T> typed) { return readWrite(Validate.notNull(typed.getType(), "type")); }