1 8 9 package com.sleepycat.persist.model; 10 11 import java.io.Serializable ; 12 import java.util.List ; 13 import java.util.Map ; 14 15 29 public class ClassMetadata implements Serializable { 30 31 private static final long serialVersionUID = -2520207423701776679L; 32 33 private String className; 34 private int version; 35 private String proxiedClassName; 36 private boolean entityClass; 37 private PrimaryKeyMetadata primaryKey; 38 private Map <String ,SecondaryKeyMetadata> secondaryKeys; 39 private List <FieldMetadata> compositeKeyFields; 40 41 44 public ClassMetadata(String className, 45 int version, 46 String proxiedClassName, 47 boolean entityClass, 48 PrimaryKeyMetadata primaryKey, 49 Map <String ,SecondaryKeyMetadata> secondaryKeys, 50 List <FieldMetadata> compositeKeyFields) { 51 this.className = className; 52 this.version = version; 53 this.proxiedClassName = proxiedClassName; 54 this.entityClass = entityClass; 55 this.primaryKey = primaryKey; 56 this.secondaryKeys = secondaryKeys; 57 this.compositeKeyFields = compositeKeyFields; 58 } 59 60 63 public String getClassName() { 64 return className; 65 } 66 67 72 public int getVersion() { 73 return version; 74 } 75 76 80 public String getProxiedClassName() { 81 return proxiedClassName; 82 } 83 84 87 public boolean isEntityClass() { 88 return entityClass; 89 } 90 91 96 public PrimaryKeyMetadata getPrimaryKey() { 97 return primaryKey; 98 } 99 100 106 public Map <String ,SecondaryKeyMetadata> getSecondaryKeys() { 107 return secondaryKeys; 108 } 109 110 118 public List <FieldMetadata> getCompositeKeyFields() { 119 return compositeKeyFields; 120 } 121 122 @Override 123 public boolean equals(Object other) { 124 if (other instanceof ClassMetadata) { 125 ClassMetadata o = (ClassMetadata) other; 126 return version == o.version && 127 entityClass == o.entityClass && 128 nullOrEqual(className, o.className) && 129 nullOrEqual(proxiedClassName, o.proxiedClassName) && 130 nullOrEqual(primaryKey, o.primaryKey) && 131 nullOrEqual(secondaryKeys, o.secondaryKeys) && 132 nullOrEqual(compositeKeyFields, o.compositeKeyFields); 133 } else { 134 return false; 135 } 136 } 137 138 @Override 139 public int hashCode() { 140 return version + 141 (entityClass ? 1 : 0) + 142 hashCode(className) + 143 hashCode(proxiedClassName) + 144 hashCode(primaryKey) + 145 hashCode(secondaryKeys) + 146 hashCode(compositeKeyFields); 147 } 148 149 static boolean nullOrEqual(Object o1, Object o2) { 150 if (o1 == null) { 151 return o2 == null; 152 } else { 153 return o1.equals(o2); 154 } 155 } 156 157 static int hashCode(Object o) { 158 if (o != null) { 159 return o.hashCode(); 160 } else { 161 return 0; 162 } 163 } 164 } 165 | Popular Tags |