/** * Check whether the user has changed this property value and it should be stored for saving in the database */ protected <TYPE> boolean shouldSaveValue(Property<TYPE> property, TYPE newValue) { return shouldSaveValue(property.getName(), newValue); }
/** * Sets the specified {@link Property} to the given value. For generated models, it is preferred to call a * generated set[Property] method instead. * * @param property the property to set * @param value the new value for the property */ public <TYPE> void set(Property<TYPE> property, TYPE value) { if (setValues == null) { setValues = newValuesStorage(); } if (!shouldSaveValue(property, value)) { return; } saver.save(property, setValues, value); }
/** * Analogous to {@link #readPropertiesFromValuesStorage(ValuesStorage, Property[])} but adds the values to the * model as set values, i.e. marks the model as dirty with these values. */ public void setPropertiesFromValuesStorage(ValuesStorage values, Property<?>... properties) { if (values != null) { if (setValues == null) { setValues = newValuesStorage(); } for (Property<?> property : properties) { String key = property.getName(); if (values.containsKey(key)) { Object value = property.accept(valueCastingVisitor, values.get(key)); if (shouldSaveValue(key, value)) { this.setValues.put(property.getName(), value, true); } } } } }
/** * Check whether the user has changed this property value and it should be stored for saving in the database */ protected <TYPE> boolean shouldSaveValue(Property<TYPE> property, TYPE newValue) { return shouldSaveValue(property.getName(), newValue); }
/** * Sets the specified {@link Property} to the given value. For generated models, it is preferred to call a * generated set[Property] method instead. * * @param property the property to set * @param value the new value for the property */ public <TYPE> void set(Property<TYPE> property, TYPE value) { if (setValues == null) { setValues = newValuesStorage(); } if (!shouldSaveValue(property, value)) { return; } saver.save(property, setValues, value); }
/** * Analogous to {@link #readPropertiesFromValuesStorage(ValuesStorage, Property[])} but adds the values to the * model as set values, i.e. marks the model as dirty with these values. */ public void setPropertiesFromValuesStorage(ValuesStorage values, Property<?>... properties) { if (values != null) { if (setValues == null) { setValues = newValuesStorage(); } for (Property<?> property : properties) { String key = property.getName(); if (values.containsKey(key)) { Object value = property.accept(valueCastingVisitor, values.get(key)); if (shouldSaveValue(key, value)) { this.setValues.put(property.getName(), value, true); } } } } }