Browse Source

add equals and hashCode to GeneratorDescriptor; needed for pre-selection in GenModel Wizard

holger.willebrandt@gmail.com 13 years ago
parent
commit
74b86df906

+ 33 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/extensions/GeneratorExtensions.java

@@ -70,6 +70,39 @@ public class GeneratorExtensions {
 			// getClass(), iconPath);
 			// return descriptor.createImage();
 		}
+
+		@Override
+		public int hashCode() {
+			String id = getId();
+			final int prime = 31;
+			int result = 1;
+			result = prime * result + ((id == null) ? 0 : id.hashCode());
+			return result;
+		}
+
+		@Override
+		public boolean equals(Object obj) {
+			if (this == obj) {
+				return true;
+			}
+			if (obj == null) {
+				return false;
+			}
+			if (getClass() != obj.getClass()) {
+				return false;
+			}
+			GeneratorDescriptor other = (GeneratorDescriptor) obj;
+			String id = getId();
+			if (id == null) {
+				if (other.getId() != null) {
+					return false;
+				}
+			} else if (!id.equals(other.getId())) {
+				return false;
+			}
+			return true;
+		}
+
 	}
 
 	public static Iterable<GeneratorDescriptor> getGeneratorDescriptors() {