/** * Default constructor. * * @param code the error or exception code of the exception. * @param propertyDescriptor the descriptor of the property raising the * exception. * @param currentValue the current value of the property that has not been * changed. * @param rejectedValue the value the property was requested to change to but * has been rejected. */ public PropertyValueChangeMessageBean(final PropertyCode code, final PropertyDescriptor propertyDescriptor, final Object currentValue, final Object rejectedValue) { super(code, null, propertyDescriptor); this.currentValue = makeSerializable(currentValue); this.rejectedValue = makeSerializable(rejectedValue); }
/** * Checks if the property identified by the given key is writable. * * @param key the key to identify the property. * @param value the new value (only used in case of an exception). * @throws ReadOnlyPropertyException if the property is read-only. * @throws UnknownPropertyException if the property referenced by {@code key} * is not known. */ private void checkWritable(final PropertyKey key, final Object value) throws ReadOnlyPropertyException, UnknownPropertyException { if (isInAdminMode()) { return; } final PropertyDescriptor descriptor = getDescriptor(key); if (!descriptor.isRuntimeMutable()) { final Object currentValue = getPropertyAsType(descriptor); throw new ReadOnlyPropertyException(new PropertyValueChangeMessageBean( PropertyCode.READ_ONLY, descriptor, currentValue, value)); } }