1.1 --- a/json/src/main/java/org/netbeans/html/json/spi/Proto.java Mon Feb 22 06:09:33 2016 +0100
1.2 +++ b/json/src/main/java/org/netbeans/html/json/spi/Proto.java Mon Feb 22 19:58:32 2016 +0100
1.3 @@ -512,7 +512,7 @@
1.4 PropertyBinding[] pb = new PropertyBinding[type.propertyNames.length];
1.5 for (int i = 0; i < pb.length; i++) {
1.6 pb[i] = b.registerProperty(
1.7 - type.propertyNames[i], i, obj, type, type.propertyReadOnly[i]
1.8 + type.propertyNames[i], i, obj, type, type.propertyType[i]
1.9 );
1.10 }
1.11 FunctionBinding[] fb = new FunctionBinding[type.functions.length];
1.12 @@ -551,7 +551,7 @@
1.13 public static abstract class Type<Model> {
1.14 private final Class<Model> clazz;
1.15 private final String[] propertyNames;
1.16 - private final boolean[] propertyReadOnly;
1.17 + private final byte[] propertyType;
1.18 private final String[] functions;
1.19
1.20 /** Constructor for subclasses generated by the annotation processor
1.21 @@ -573,7 +573,7 @@
1.22 }
1.23 this.clazz = clazz;
1.24 this.propertyNames = new String[properties];
1.25 - this.propertyReadOnly = new boolean[properties];
1.26 + this.propertyType = new byte[properties];
1.27 this.functions = new String[functions];
1.28 JSON.register(clazz, this);
1.29 }
1.30 @@ -588,7 +588,29 @@
1.31 protected final void registerProperty(String name, int index, boolean readOnly) {
1.32 assert propertyNames[index] == null;
1.33 propertyNames[index] = name;
1.34 - propertyReadOnly[index] = readOnly;
1.35 + propertyType[index] = (byte) (readOnly ? 1 : 0);
1.36 + }
1.37 +
1.38 + /** Registers property for the type. It is expected each index
1.39 + * is initialized only once. The difference between <code>readOnly</code>
1.40 + * and <code>constant</code> is: The <code>constant</code> value is
1.41 + * assigned only at the beginning and never changed then - like the
1.42 + * {@link Property#mutable() non-mutable} property. On the other
1.43 + * hand, a <code>readOnly</code> property can change its value,
1.44 + * but not via a setter - just like {@link ComputedProperty}.
1.45 + *
1.46 + * @param name name of the property
1.47 + * @param index index of the property
1.48 + * @param readOnly is the property read only?
1.49 + * @param constant is the property assigned once and never changed again?
1.50 + * @since 1.3
1.51 + */
1.52 + protected final void registerProperty(
1.53 + String name, int index, boolean readOnly, boolean constant
1.54 + ) {
1.55 + assert propertyNames[index] == null;
1.56 + propertyNames[index] = name;
1.57 + propertyType[index] = (byte) ((readOnly ? 1 : 0) | (constant ? 2 : 0));
1.58 }
1.59
1.60 /** Registers function of given name at given index.