1 19 20 package org.netbeans.api.java.platform; 21 22 import org.openide.modules.SpecificationVersion; 23 24 26 public final class Specification { 27 28 private String name; 29 private SpecificationVersion version; 30 private Profile[] profiles; 31 32 33 38 public Specification (String name, SpecificationVersion version) { 39 this (name, version, null); 40 } 41 42 48 public Specification (String name, SpecificationVersion version, Profile[] profiles) { 49 this.name = name; 50 this.version = version; 51 this.profiles = profiles; 52 } 53 54 58 public final String getName () { 59 return this.name; 60 } 61 62 66 public final SpecificationVersion getVersion () { 67 return this.version; 68 } 69 70 74 public final Profile[] getProfiles () { 75 return this.profiles; 76 } 77 78 public int hashCode () { 79 int hc = 0; 80 if (this.name != null) 81 hc = this.name.hashCode() << 16; 82 if (this.version != null) 83 hc += this.version.hashCode(); 84 return hc; 85 } 86 87 public boolean equals (Object other) { 88 if (other instanceof Specification) { 89 Specification os = (Specification) other; 90 boolean re = this.name == null ? os.name == null : this.name.equals(os.name) && 91 this.version == null ? os.version == null : this.version.equals (os.version); 92 if (!re || this.profiles == null) 93 return re; 94 if (os.profiles == null || this.profiles.length != os.profiles.length) 95 return false; 96 for (int i=0; i<os.profiles.length; i++) 97 re &= this.profiles[i].equals(os.profiles[i]); 98 return re; 99 } 100 else 101 return false; 102 } 103 104 public String toString () { 105 String str = this.name == null ? "" : this.name + " "; str += this.version == null ? "" : this.version + " "; if (this.profiles != null) { 108 str+="["; for (int i = 0; i < profiles.length; i++) { 110 str+= profiles[i]+ " "; } 112 str+="]"; } 114 return str; 115 } 116 117 } 118 | Popular Tags |