Hi Daniel,You could try to load the class using: Class.forName and then attempt to check if the class isAssignableFrom(Number.class)This will not work if the class does not belong to the current classloader, but I am not sure if you're going to run into this issue specifically.Hi folks,
I want do that:
type instanceof Number.
That case, my type can be AtomicInteger, AtomicLong, BigDecimal, BigInteger, Byte, Double, Float, Integer, Long and Short
Eg:.
public static Type<?> getIdType(JavaClass<?> entity) { for (Member<?> member : entity.getMembers()) { if (member.hasAnnotation(Id.class)) { if (member instanceof Method) { return ((Method<?, ?>) member).getReturnType(); } if (member instanceof Field) { return ((Field<?>) member).getType(); } } } return null; }
public static boolean isNumberIdType(JavaClass<?> entity) { return getIdType(entity) instanceof Number; }
I see the code and I don’t see a simple form to do it.
How I do that with Roaster Type<?>?I thought to do that in Types (roaster util):
public static boolean isNumber(final String type) { if (isBasicType(type)) { if (isPrimitive(type)) { return Arrays.asList("int", "long", "float", "double", "short").contains(type); } return Arrays.asList("Boolean", "Byte", "Double", "Float", "Integer", "Long", "Short").contains( type); } return false; }
But, it isn’t good.
--Daniel Cunha (soro) <http://www.cejug.net>
Twitter: https://twitter.com/dvlc_GitHub: https://github.com/danielsoro_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev
_______________________________________________
forge-dev mailing list
forge-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev