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