in src/main/java/org/apache/sling/jackrabbit/usermanager/impl/resource/BaseAuthorizableValueMap.java [294:329]
private <T> T convertToType(Value jcrValue, Class<T> type)
throws RepositoryException {
if (String.class == type) {
return (T) jcrValue.getString();
} else if (Byte.class == type) {
return (T) Byte.valueOf((byte) jcrValue.getLong());
} else if (BigDecimal.class == type) {
return (T) jcrValue.getDecimal();
} else if (Short.class == type) {
return (T) Short.valueOf((short) jcrValue.getLong());
} else if (Integer.class == type) {
return (T) Integer.valueOf((int) jcrValue.getLong());
} else if (Long.class == type) {
return (T) Long.valueOf(jcrValue.getLong());
} else if (Float.class == type) {
return (T) Float.valueOf((float)jcrValue.getDouble());
} else if (Double.class == type) {
return (T) Double.valueOf(jcrValue.getDouble());
} else if (Boolean.class == type) {
return (T) Boolean.valueOf(jcrValue.getBoolean());
} else if (Date.class == type) {
return (T) jcrValue.getDate().getTime();
} else if (Calendar.class == type) {
return (T) jcrValue.getDate();
} else if (Binary.class == type) {
return (T) jcrValue.getBinary();
} else if (InputStream.class == type) {
return (T) jcrValue.getBinary().getStream();
} else if (Value.class == type) {
return (T) jcrValue;
}
// fallback in case of unsupported type
return null;
}