View Javadoc

1   /**
2    * 
3    */
4   package org.sourceforge.jemm.database;
5   
6   import java.io.Serializable;
7   import java.util.Collections;
8   import java.util.HashMap;
9   import java.util.Map;
10  
11  /**
12   * @author Rory Graves
13   */
14  public class ObjectSyncResp implements Serializable {
15  	private static final long serialVersionUID = 1L;
16  	
17  	private final int newVersionNo;
18      private final Map<FieldInfo,Object> updatedFields;
19  
20      public ObjectSyncResp(int newVersionNo,Map<FieldInfo,Object> updatedFields) {
21          this.newVersionNo = newVersionNo;
22          Map<FieldInfo,Object> tmpMap = new HashMap<FieldInfo, Object>();
23          tmpMap.putAll(updatedFields);
24          this.updatedFields = Collections.unmodifiableMap(tmpMap);
25      }
26  
27  	@Override
28  	public int hashCode() {
29  		final int prime = 31;
30  		int result = 1;
31  		result = prime * result + newVersionNo;
32  		result = prime * result
33  				+ ((updatedFields == null) ? 0 : updatedFields.hashCode());
34  		return result;
35  	}
36  
37  	@Override
38  	public boolean equals(Object obj) {
39  		if (this == obj)
40  			return true;
41  		if (obj == null)
42  			return false;
43  		if (getClass() != obj.getClass())
44  			return false;
45  		ObjectSyncResp other = (ObjectSyncResp) obj;
46  		if (newVersionNo != other.newVersionNo)
47  			return false;
48  		if (updatedFields == null) {
49  			if (other.updatedFields != null)
50  				return false;
51  		} else if (!updatedFields.equals(other.updatedFields))
52  			return false;
53  		return true;
54  	}
55  
56  	public int getNewVersionNo() {
57  		return newVersionNo;
58  	}
59  
60  	public Map<FieldInfo,Object> getUpdatedFields() {
61  		return updatedFields;
62  	}
63  }