private void prepareToReadProperties() { if (values == null) { values = newValuesStorage(); } // clears user-set values setValues = null; transitoryData = null; }
@Override public AbstractModel clone() { AbstractModel clone; try { clone = (AbstractModel) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } if (setValues != null) { clone.setValues = newValuesStorage(); clone.setValues.putAll(setValues); } if (values != null) { clone.values = newValuesStorage(); clone.values.putAll(values); } if (transitoryData != null) { clone.transitoryData = new HashMap<>(transitoryData); } return clone; }
/** * 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); }
/** @return a mapping of all field/value pairs merged across data sources */ public ValuesStorage getMergedValues() { ValuesStorage mergedValues = newValuesStorage(); ValuesStorage defaultValues = getDefaultValues(); if (defaultValues != null) { mergedValues.putAll(defaultValues); } if (values != null) { mergedValues.putAll(values); } if (setValues != null) { mergedValues.putAll(setValues); } return mergedValues; }
/** * 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); } } } } }
private void prepareToReadProperties() { if (values == null) { values = newValuesStorage(); } // clears user-set values setValues = null; transitoryData = null; }
@Override public AbstractModel clone() { AbstractModel clone; try { clone = (AbstractModel) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } if (setValues != null) { clone.setValues = newValuesStorage(); clone.setValues.putAll(setValues); } if (values != null) { clone.values = newValuesStorage(); clone.values.putAll(values); } if (transitoryData != null) { clone.transitoryData = new HashMap<>(transitoryData); } return clone; }
/** * 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); }
/** @return a mapping of all field/value pairs merged across data sources */ public ValuesStorage getMergedValues() { ValuesStorage mergedValues = newValuesStorage(); ValuesStorage defaultValues = getDefaultValues(); if (defaultValues != null) { mergedValues.putAll(defaultValues); } if (values != null) { mergedValues.putAll(values); } if (setValues != null) { mergedValues.putAll(setValues); } return mergedValues; }
/** * 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); } } } } }