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.