1.1 --- a/json/src/main/java/org/netbeans/html/json/spi/PropertyBinding.java Sun Dec 13 21:12:26 2015 +0100
1.2 +++ b/json/src/main/java/org/netbeans/html/json/spi/PropertyBinding.java Mon Feb 22 19:58:32 2016 +0100
1.3 @@ -45,6 +45,7 @@
1.4 import java.lang.ref.Reference;
1.5 import java.lang.ref.WeakReference;
1.6 import net.java.html.BrwsrCtx;
1.7 +import net.java.html.json.ComputedProperty;
1.8 import org.netbeans.html.json.impl.Bindings;
1.9 import org.netbeans.html.json.impl.JSON;
1.10 import org.netbeans.html.json.impl.PropertyBindingAccessor;
1.11 @@ -93,10 +94,8 @@
1.12
1.13 @Override
1.14 protected <M> PropertyBinding newBinding(
1.15 - Proto.Type<M> access, Bindings<?> bindings, String name,
1.16 - int index, M model, boolean readOnly
1.17 - ) {
1.18 - return new Impl(model, bindings, name, index, access, readOnly);
1.19 + Proto.Type<M> access, Bindings<?> bindings, String name, int index, M model, byte propertyType) {
1.20 + return new Impl(model, bindings, name, index, access, propertyType);
1.21 }
1.22 };
1.23 }
1.24 @@ -121,12 +120,22 @@
1.25 */
1.26 public abstract Object getValue();
1.27
1.28 - /** Is this property read only? Or can one call {@link #setValue(java.lang.Object)}?
1.29 + /** Is this property read only?. Or can one call {@link #setValue(java.lang.Object)}?
1.30 + * The property can still change, but only as a result of other
1.31 + * properties being changed, just like {@link ComputedProperty} can.
1.32 *
1.33 * @return true, if this property is read only
1.34 */
1.35 public abstract boolean isReadOnly();
1.36
1.37 + /** Is this property constant?. If a property is constant, than its
1.38 + * value cannot changed after it is read.
1.39 + *
1.40 + * @return true, if this property is constant
1.41 + * @since 1.3
1.42 + */
1.43 + public abstract boolean isConstant();
1.44 +
1.45 /** Returns identical version of the binding, but one that holds on the
1.46 * original model object via weak reference.
1.47 *
1.48 @@ -137,17 +146,17 @@
1.49
1.50 private static abstract class AImpl<M> extends PropertyBinding {
1.51 public final String name;
1.52 - public final boolean readOnly;
1.53 + public final byte propertyType;
1.54 final Proto.Type<M> access;
1.55 final Bindings<?> bindings;
1.56 final int index;
1.57
1.58 - public AImpl(Bindings<?> bindings, String name, int index, Proto.Type<M> access, boolean readOnly) {
1.59 + public AImpl(Bindings<?> bindings, String name, int index, Proto.Type<M> access, byte propertyType) {
1.60 this.bindings = bindings;
1.61 this.name = name;
1.62 this.index = index;
1.63 this.access = access;
1.64 - this.readOnly = readOnly;
1.65 + this.propertyType = propertyType;
1.66 }
1.67
1.68 protected abstract M model();
1.69 @@ -174,7 +183,12 @@
1.70
1.71 @Override
1.72 public boolean isReadOnly() {
1.73 - return readOnly;
1.74 + return (propertyType & 1) != 0;
1.75 + }
1.76 +
1.77 + @Override
1.78 + public boolean isConstant() {
1.79 + return (propertyType & 2) != 0;
1.80 }
1.81
1.82 @Override
1.83 @@ -186,8 +200,8 @@
1.84 private static final class Impl<M> extends AImpl<M> {
1.85 private final M model;
1.86
1.87 - public Impl(M model, Bindings<?> bindings, String name, int index, Proto.Type<M> access, boolean readOnly) {
1.88 - super(bindings, name, index, access, readOnly);
1.89 + public Impl(M model, Bindings<?> bindings, String name, int index, Proto.Type<M> access, byte propertyType) {
1.90 + super(bindings, name, index, access, propertyType);
1.91 this.model = model;
1.92 }
1.93
1.94 @@ -198,14 +212,14 @@
1.95
1.96 @Override
1.97 public PropertyBinding weak() {
1.98 - return new Weak(model, bindings, name, index, access, readOnly);
1.99 + return new Weak(model, bindings, name, index, access, propertyType);
1.100 }
1.101 }
1.102
1.103 private static final class Weak<M> extends AImpl<M> {
1.104 private final Reference<M> ref;
1.105 - public Weak(M model, Bindings<?> bindings, String name, int index, Proto.Type<M> access, boolean readOnly) {
1.106 - super(bindings, name, index, access, readOnly);
1.107 + public Weak(M model, Bindings<?> bindings, String name, int index, Proto.Type<M> access, byte propertyType) {
1.108 + super(bindings, name, index, access, propertyType);
1.109 this.ref = new WeakReference<M>(model);
1.110 }
1.111