1 11 package org.eclipse.ui.internal.dialogs; 12 13 import org.eclipse.core.runtime.Assert; 14 15 20 final class PreferenceHistoryEntry { 21 private String id; 22 private String label; 23 private Object argument; 24 25 33 public PreferenceHistoryEntry(String id, String label, Object argument) { 34 Assert.isLegal(id != null); 35 Assert.isLegal(label != null); 36 this.id= id; 37 this.label= label; 38 this.argument= argument; 39 } 40 45 public String getId() { 46 return id; 47 } 48 53 public Object getArgument() { 54 return argument; 55 } 56 61 public String getLabel() { 62 return label; 63 } 64 67 public String toString() { 68 if (argument == null) { 69 return id; 70 } 71 return id + "(" + argument + ")"; } 73 76 public boolean equals(Object obj) { 77 if (obj instanceof PreferenceHistoryEntry) { 78 PreferenceHistoryEntry other= (PreferenceHistoryEntry) obj; 79 return id.equals(other.id) 80 && (argument == null && other.argument == null 81 || argument.equals(other.argument)); 82 } 83 return super.equals(obj); 84 } 85 88 public int hashCode() { 89 int argHash= argument == null ? 0 : argument.hashCode() & 0x0000ffff; 90 return id.hashCode() << 16 | argHash; 91 } 92 } 93 | Popular Tags |