Code example for Field

Methods: getDeclaringClassset

0
	 */ 
	public static void setObjectField(Property property, Field field, Object object)
			throws RepositoryException, IllegalAccessException { 
		Value value = property.getValue();
 
		Class<?> declaringClass = field.getDeclaringClass();
		if (declaringClass.isAssignableFrom(Boolean.class)) {
			field.set(object, value.getBoolean());
		} else if (declaringClass.isAssignableFrom(Calendar.class)) {
			field.set(object, value.getDate());
		} else if (declaringClass.isAssignableFrom(Double.class)) {
			field.set(object, value.getDouble());
		} else if (declaringClass.isAssignableFrom(InputStream.class)) {
			field.set(object, value.getBinary().getStream());
		} else if (declaringClass.isAssignableFrom(Long.class)) {
			field.set(object, value.getLong());
		} else if (declaringClass.isAssignableFrom(String.class)) {
			field.set(object, value.getString());
		} else { 
			// cannot assign the field 
			throw new IllegalArgumentException();
		} 
	} 
Contextual code suggestions in your IDE  Get Codota for Java