1 11 package org.eclipse.pde.internal.ui.editor.site; 12 13 import java.io.PrintWriter ; 14 import java.io.Serializable ; 15 16 import org.eclipse.pde.core.IWritable; 17 import org.eclipse.pde.internal.core.isite.ISiteFeature; 18 19 public class SiteFeatureAdapter implements Serializable , IWritable { 20 21 private static final long serialVersionUID = 1L; 22 23 String category; 24 ISiteFeature feature; 25 26 public SiteFeatureAdapter(String category, ISiteFeature feature) { 27 this.category = category; 28 this.feature = feature; 29 } 30 31 34 public void write(String indent, PrintWriter writer) { 35 feature.write(indent, writer); 36 } 37 38 44 public boolean equals(Object obj) { 45 if (obj instanceof SiteFeatureAdapter) { 46 SiteFeatureAdapter adapter = (SiteFeatureAdapter) obj; 47 String id = feature.getId(); 48 String id2 = adapter.feature.getId(); 49 boolean sameFeature = id != null && id2 != null && id.equals(id2); 50 if (sameFeature) { 51 String version = feature.getVersion(); 52 String version2 = adapter.feature.getVersion(); 53 sameFeature = version != null && version2 != null && version.equals(version2); 54 } 55 boolean sameCategory = adapter.category != null && category != null 56 ? adapter.category.equals(category) : true; 57 return sameFeature && sameCategory; 58 } 59 return super.equals(obj); 60 } 61 64 public int hashCode() { 65 int code = feature.getId().hashCode()+feature.getVersion().hashCode(); 66 if(category!=null){ 67 code+=category.hashCode(); 68 } 69 return code; 70 } 71 } 72 | Popular Tags |