1 11 12 package org.eclipse.ui.internal.commands; 13 14 import org.eclipse.ui.internal.util.Util; 15 16 public final class ActiveKeyConfigurationDefinition 17 implements Comparable { 18 19 private final static int HASH_FACTOR = 89; 20 private final static int HASH_INITIAL = 21 ActiveKeyConfigurationDefinition.class.getName().hashCode(); 22 23 private transient int hashCode; 24 private transient boolean hashCodeComputed; 25 26 private String keyConfigurationId; 27 private String sourceId; 28 private transient String string; 29 30 public ActiveKeyConfigurationDefinition( 31 String keyConfigurationId, 32 String sourceId) { 33 this.keyConfigurationId = keyConfigurationId; 34 this.sourceId = sourceId; 35 } 36 37 public int compareTo(Object object) { 38 ActiveKeyConfigurationDefinition castedObject = 39 (ActiveKeyConfigurationDefinition) object; 40 int compareTo = 41 Util.compare(keyConfigurationId, castedObject.keyConfigurationId); 42 43 if (compareTo == 0) 44 compareTo = Util.compare(sourceId, castedObject.sourceId); 45 46 return compareTo; 47 } 48 49 public boolean equals(Object object) { 50 if (!(object instanceof ActiveKeyConfigurationDefinition)) 51 return false; 52 53 ActiveKeyConfigurationDefinition castedObject = 54 (ActiveKeyConfigurationDefinition) object; 55 boolean equals = true; 56 equals 57 &= Util.equals(keyConfigurationId, castedObject.keyConfigurationId); 58 equals &= Util.equals(sourceId, castedObject.sourceId); 59 return equals; 60 } 61 62 public String getKeyConfigurationId() { 63 return keyConfigurationId; 64 } 65 66 public String getSourceId() { 67 return sourceId; 68 } 69 70 public int hashCode() { 71 if (!hashCodeComputed) { 72 hashCode = HASH_INITIAL; 73 hashCode = 74 hashCode * HASH_FACTOR + Util.hashCode(keyConfigurationId); 75 hashCode = hashCode * HASH_FACTOR + Util.hashCode(sourceId); 76 hashCodeComputed = true; 77 } 78 79 return hashCode; 80 } 81 82 public String toString() { 83 if (string == null) { 84 final StringBuffer stringBuffer = new StringBuffer (); 85 stringBuffer.append('['); 86 stringBuffer.append(keyConfigurationId); 87 stringBuffer.append(','); 88 stringBuffer.append(sourceId); 89 stringBuffer.append(']'); 90 string = stringBuffer.toString(); 91 } 92 93 return string; 94 } 95 } 96 | Popular Tags |