public void readAndSetProperty(Object obj, Property property) throws IOException, ClassNotFoundException, IllegalAccessException, InvocationTargetException { if (property.isAnnotationPresent(Include.class) && !property.isWritable()) property = new NoopWritableProperty(property.getName(), property.getType()); if (property.getType().isPrimitive()) codecRegistry.getPrimitivePropertyCodec(property.getType()).decodePrimitive(this, obj, property); else property.setObject(obj, readObject()); }
@Override public boolean getBoolean(Object holder) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (ObservableBooleanValue.class.isAssignableFrom(property.getType())) return ((ObservableBooleanValue)property.getObject(holder)).get(); return property.getBoolean(holder); }
@Override public byte getByte(Object holder) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (ObservableValue.class.isAssignableFrom(property.getType())) throw new UnsupportedOperationException("JavaFX doesn't support byte properties"); return property.getByte(holder); }
@Override public short getShort(Object holder) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (ObservableValue.class.isAssignableFrom(property.getType())) throw new UnsupportedOperationException("JavaFX doesn't support short properties"); return property.getShort(holder); }
@Override public double getDouble(Object holder) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (ObservableDoubleValue.class.isAssignableFrom(property.getType())) return ((ObservableDoubleValue)property.getObject(holder)).get(); return property.getDouble(holder); }
continue; if (!includeReadOnly && !property.isWritable()) continue; values.put(property.getName(), raw ? property.getRawObject(entity) : property.getObject(entity)); throw new RuntimeException("Could not get property " + property.getName() + " on entity " + entity, e);
@Override public String getName() { return property.getName(); }
@Override public void setBoolean(Object holder, boolean value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (WritableBooleanValue.class.isAssignableFrom(property.getType())) ((WritableBooleanValue)property.getObject(holder)).set(value); else property.setBoolean(holder, value); }
@Override public void setFloat(Object holder, float value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (WritableFloatValue.class.isAssignableFrom(property.getType())) ((WritableFloatValue)property.getObject(holder)).set(value); else property.setFloat(holder, value); }
@Override public void setDouble(Object holder, double value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (WritableDoubleValue.class.isAssignableFrom(property.getType())) ((WritableDoubleValue)property.getObject(holder)).set(value); else property.setDouble(holder, value); }
@Override public void setInt(Object holder, int value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (WritableIntegerValue.class.isAssignableFrom(property.getType())) ((WritableIntegerValue)property.getObject(holder)).set(value); else property.setInt(holder, value); }
@Override public float getFloat(Object holder) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (ObservableFloatValue.class.isAssignableFrom(property.getType())) return ((ObservableFloatValue)property.getObject(holder)).get(); return property.getFloat(holder); }
@Override public void setLong(Object holder, long value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (WritableLongValue.class.isAssignableFrom(property.getType())) ((WritableLongValue)property.getObject(holder)).set(value); else property.setLong(holder, value); }
public void getAndWriteProperty(Object obj, Property property) throws IOException, IllegalAccessException, InvocationTargetException { if (property.getType().isPrimitive()) codecRegistry.getPrimitivePropertyCodec(property.getType()).encodePrimitive(this, obj, property); else writeObject(property.getObject(obj)); } }
@Override public Object getRawObject(Object holder) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { Object fieldValue = property.getObject(holder); if (fieldValue instanceof ObservableValue) return ((ObservableValue<?>)fieldValue).getValue(); return fieldValue; }
@Override @SuppressWarnings("unchecked") public void setObject(Object holder, Object value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { Class<?> fieldType = property.getType(); WritableValue<Object> writableValue = (WritableValue<Object>)property.getObject(holder); property.setObject(holder, value);
public Object getPropertyValue(Object entity, String name, boolean raw) { Property property = reflection.findSerializableProperty(entity.getClass(), name); try { return raw ? property.getRawObject(entity) : property.getObject(entity); } catch (Exception e) { throw new RuntimeException("Could not get " + property + " of object " + entity); } }
@Override public char getChar(Object holder) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (ObservableValue.class.isAssignableFrom(property.getType())) throw new UnsupportedOperationException("JavaFX doesn't support char properties"); return property.getChar(holder); }