/** * * @param object * The object which fields should be visited. * @return {@code true} when the object was a observable object, {@code false} when it was a simple object. * @throws SecurityException * If a {@link SecurityManager} is active and denies access to fields via reflection. * @throws IllegalAccessException * If access modifiers like {@code private} are enforced even when the model is accessed via reflection. */ private boolean visitFields(final Object object) throws IllegalAccessException { boolean isObservableObject = false; for (final Field field : getInheritedFields(object.getClass())) { field.setAccessible(true); currentField = field; final Class<?> fieldClass = field.getType(); if (!isObservableObject && classImplementsOrExtends(fieldClass, Property.class)) { startVisiting(object); isObservableObject = true; } if (classImplementsOrExtends(fieldClass, ListProperty.class)) { handle((ListProperty<?>) field.get(object)); } else if (classImplementsOrExtends(fieldClass, SetProperty.class)) { handle((SetProperty<?>) field.get(object)); } else if (classImplementsOrExtends(fieldClass, MapProperty.class)) { handle((MapProperty<?, ?>) field.get(object)); } else if (classImplementsOrExtends(fieldClass, Property.class)) { handle((Property<?>) field.get(object)); } } return isObservableObject; }
/** * Provides the underlying value class for a given {@link Property} * * @param property * the {@link Property} to check * @return the value class of the {@link Property} */ @SuppressWarnings("unchecked") protected static <T> Class<T> propertyValueClass(final Property<T> property) { Class<T> clazz = null; if (property != null) { if (StringProperty.class.isAssignableFrom(property.getClass())) { clazz = (Class<T>) String.class; } else if (IntegerProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Integer.class; } else if (BooleanProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Boolean.class; } else if (DoubleProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Double.class; } else if (FloatProperty.class .isAssignableFrom(property.getClass())) { clazz = (Class<T>) Float.class; } else if (LongProperty.class.isAssignableFrom(property.getClass())) { clazz = (Class<T>) Long.class; } else if (ListProperty.class.isAssignableFrom(property.getClass())) { clazz = (Class<T>) List.class; } else if (MapProperty.class.isAssignableFrom(property.getClass())) { clazz = (Class<T>) Map.class; } else { clazz = (Class<T>) Object.class; } } return clazz; }
/** * Provides the underlying value class for a given {@linkplain Property} * * @param property * the {@linkplain Property} to check * @return the value class of the {@linkplain Property} */ @SuppressWarnings("unchecked") protected static <T> Class<T> propertyValueClass(final Property<T> property) { Class<T> clazz = null; if (property != null) { if (StringProperty.class.isAssignableFrom(property.getClass())) { clazz = (Class<T>) String.class; } else if (IntegerProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Integer.class; } else if (BooleanProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Boolean.class; } else if (DoubleProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Double.class; } else if (FloatProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Float.class; } else if (LongProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Long.class; } else if (ListProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) List.class; } else if (MapProperty.class.isAssignableFrom(property .getClass())) { clazz = (Class<T>) Map.class; } else { clazz = (Class<T>) Object.class; } } return clazz; }
private void handle(final MapProperty<?, ?> property) throws IllegalAccessException { if (visitCollectionProperty(property)) { for (Entry<?, ?> entry : property.entrySet()) { visit(entry.getKey()); visit(entry.getValue()); } } }
Parent(final Property<?> parentProperty, final ListProperty<?> parentList, final SetProperty<?> parentSet, final MapProperty<?, ?> parentMap) { this.parentList = parentList; this.parentSet = parentSet; this.parentMap = parentMap; this.parentProperty = parentProperty; }
@NotNull @Override protected MapProperty<K, V> createProperty(ObservableMap<K, V> deserializedValue) { return new SimpleMapProperty<>(deserializedValue); }
public MapProperty<String, String> customizedCommandlineVariablesProperty() { return customizedCommandlineVariablesProperty; }
public final MapProperty<YearMonth, Collection<DateBean>> yearMonth2DateBeanMapProperty() { return this.yearMonth2DateBeanMap; }
public final MapProperty<LocalDate, Number> dayToNetEarningsProperty() { return this.dayToNetEarnings; }
public final MapProperty<YearMonth, Number> yearMonthToNetEarningsProperty() { return this.yearMonthToNetEarnings; }
public final MapProperty<String, Number> earningsPerOriginProperty() { return this.earningsPerOrigin; }
public MapProperty<Variable<Number>, TopsoilDataColumn> selectionsProperty() { if (selectionsProperty == null) { selectionsProperty = new SimpleMapProperty<>(FXCollections.observableHashMap()); } return selectionsProperty; }
public final MapProperty<String, MenuItemModel> currentMenuItemsProperty(){ return this.currentMenuItems; }
public MapProperty<String, String> parameterProperty() { return this.parameterProperty; }
/** * Visit a field of type {@link MapProperty}. * * @param fieldValue * The value that is bound to the field. * @return {@code true} if the childs of this property should be visited, {@code false} if not. */ protected abstract boolean visitCollectionProperty(MapProperty<?, ?> fieldValue);
/** * @return The parent {@link MapProperty} if the parent of the current object is a {@link MapProperty}. If not or if * this is the root element and therefore their is no parent {@code null} is returned. */ public MapProperty<?, ?> getParentMap() { return parent.peek().parentMap; }
/** * Registers listeners on a property so that commands are created when changes in the property occur. * * @param map * The property to register the change listeners on. */ public void registerOn(final MapProperty<?, ?> map) { map.addListener(mapListener); }