/**
 *
 */
package org.commcare.suite.model;

import org.javarosa.core.util.externalizable.DeserializationException;
import org.javarosa.core.util.externalizable.ExtUtil;
import org.javarosa.core.util.externalizable.Externalizable;
import org.javarosa.core.util.externalizable.PrototypeFactory;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * This is just a tiny little struct to make it reasonable to maintain
 * the properties until they are installed. Unfortunately, the serialization
 * framework requires it to be public.
 *
 * @author ctsims
 */
public class PropertySetter implements Externalizable {
    String key;
    String value;
    boolean force;

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public boolean isForce() {
        return force;
    }

    /**
     * Serialization Only!!!
     */
    public PropertySetter() {

    }

    protected PropertySetter(String key, String value, boolean force) {
        this.key = key;
        this.value = value;
        this.force = force;
    }

    public void readExternal(DataInputStream in, PrototypeFactory pf)
            throws IOException, DeserializationException {
        key = ExtUtil.readString(in);
        value = ExtUtil.readString(in);
        force = ExtUtil.readBool(in);
    }

    public void writeExternal(DataOutputStream out) throws IOException {
        ExtUtil.writeString(out, key);
        ExtUtil.writeString(out, value);
        ExtUtil.writeBool(out, force);
    }

    public boolean equals(Object o) {
        if(!(o instanceof PropertySetter)) {
            return false;
        }
        
        PropertySetter p = (PropertySetter)o;
        return this.key.equals(p.getKey()) && 
               this.value.equals(p.getValue()) && 
               force == p.force;
    }
}
@@ -1,15 +1,4 @@
-/**%0A *%0A */%0A
 pack
@@ -698,16 +698,98 @@
 force;%0A%0A
+    /**%0A     * Serialization Only!!!%0A     */%0A    public PropertySetter() %7B%0A    %7D%0A%0A
     publ
@@ -960,91 +960,8 @@
  %7D%0A%0A
-    /**%0A     * Serialization Only!!!%0A     */%0A    public PropertySetter() %7B%0A%0A    %7D%0A%0A
     
@@ -1107,32 +1107,46 @@
 = force;%0A    %7D%0A%0A
+    @Override%0A
     public void 
@@ -1373,32 +1373,46 @@
 ool(in);%0A    %7D%0A%0A
+    @Override%0A
     public void 
@@ -1586,32 +1586,46 @@
  force);%0A    %7D%0A%0A
+    @Override%0A
     public boole
@@ -1656,16 +1656,17 @@
       if
+ 
 (!(o ins
@@ -1732,17 +1732,9 @@
   %7D%0A
-        
 %0A
+
     
@@ -1816,26 +1816,26 @@
 getKey()) &&
- 
 %0A
+ 
             
@@ -1875,10 +1875,10 @@
 ) &&
- 
 %0A
+ 
     
@@ -1911,10 +1911,251 @@
 e;%0A    %7D
+%0A%0A    @Override%0A    public int hashCode() %7B%0A        int result = 11;%0A        result = 31 * result + key.hashCode();%0A        result = 31 * result + value.hashCode();%0A        result = 31 * result + (force ? 0 : 1);%0A        return result;%0A    %7D
 %0A%7D

Add hashCode to PropertySetter