Lines 44-58
Link Here
|
44 |
|
44 |
|
45 |
package org.netbeans.api.java.platform; |
45 |
package org.netbeans.api.java.platform; |
46 |
|
46 |
|
|
|
47 |
import java.util.Locale; |
48 |
import org.netbeans.api.annotations.common.NonNull; |
49 |
import org.netbeans.api.annotations.common.NullAllowed; |
47 |
import org.openide.modules.SpecificationVersion; |
50 |
import org.openide.modules.SpecificationVersion; |
|
|
51 |
import org.openide.util.Parameters; |
48 |
|
52 |
|
49 |
/** Specification of the Java SDK |
53 |
/** Specification of the Java SDK |
50 |
*/ |
54 |
*/ |
51 |
public final class Specification { |
55 |
public final class Specification { |
52 |
|
56 |
|
53 |
private String name; |
57 |
private final String name; |
54 |
private SpecificationVersion version; |
58 |
private final SpecificationVersion version; |
55 |
private Profile[] profiles; |
59 |
private final Profile[] profiles; |
|
|
60 |
private final String displayName; |
56 |
|
61 |
|
57 |
|
62 |
|
58 |
/** |
63 |
/** |
Lines 60-67
Link Here
|
60 |
* @param name of the specification e.g J2SE |
65 |
* @param name of the specification e.g J2SE |
61 |
* @param version of the specification e.g. 1.4 |
66 |
* @param version of the specification e.g. 1.4 |
62 |
*/ |
67 |
*/ |
63 |
public Specification (String name, SpecificationVersion version) { |
68 |
public Specification (@NonNull String name, @NonNull SpecificationVersion version) { |
64 |
this (name, version, null); |
69 |
this (name, version, null, null); |
|
|
70 |
} |
71 |
|
72 |
/** |
73 |
* Creates new SDK Specification |
74 |
* @param name of the specification e.g J2SE |
75 |
* @param version of the specification e.g. 1.4 |
76 |
* @param displayName the display name of the Java SDK e.g. "Java SE". |
77 |
* @since 1.26 |
78 |
*/ |
79 |
public Specification ( |
80 |
@NonNull final String name, |
81 |
@NonNull final SpecificationVersion version, |
82 |
@NullAllowed final String displayName) { |
83 |
this (name, version, displayName, null); |
65 |
} |
84 |
} |
66 |
|
85 |
|
67 |
/** |
86 |
/** |
Lines 70-78
Link Here
|
70 |
* @param version of the specification e.g. 1.4 |
89 |
* @param version of the specification e.g. 1.4 |
71 |
* @param profiles of the Java SDK |
90 |
* @param profiles of the Java SDK |
72 |
*/ |
91 |
*/ |
73 |
public Specification (String name, SpecificationVersion version, Profile[] profiles) { |
92 |
public Specification ( |
|
|
93 |
@NonNull final String name, |
94 |
@NonNull final SpecificationVersion version, |
95 |
@NullAllowed final Profile[] profiles) { |
96 |
this(name, version, null, profiles); |
97 |
} |
98 |
|
99 |
/** |
100 |
* Creates new SDK Specification |
101 |
* @param name of the specification e.g J2SE |
102 |
* @param version of the specification e.g. 1.4 |
103 |
* @param displayName the display name of the Java SDK e.g. "Java SE". |
104 |
* @param profiles of the Java SDK |
105 |
* @since 1.26 |
106 |
*/ |
107 |
public Specification ( |
108 |
@NonNull final String name, |
109 |
@NonNull final SpecificationVersion version, |
110 |
@NullAllowed final String displayName, |
111 |
@NullAllowed final Profile[] profiles) { |
112 |
Parameters.notNull("name", name); //NOI18N |
113 |
Parameters.notNull("version", version); //NOI18N |
74 |
this.name = name; |
114 |
this.name = name; |
75 |
this.version = version; |
115 |
this.version = version; |
|
|
116 |
this.displayName = displayName; |
76 |
this.profiles = profiles; |
117 |
this.profiles = profiles; |
77 |
} |
118 |
} |
78 |
|
119 |
|
Lines 99-105
Link Here
|
99 |
public final Profile[] getProfiles () { |
140 |
public final Profile[] getProfiles () { |
100 |
return this.profiles; |
141 |
return this.profiles; |
101 |
} |
142 |
} |
|
|
143 |
|
144 |
/** |
145 |
* Returns the display name of the Java SDK. |
146 |
* While the {@link Specification#getName()} is used as a system name |
147 |
* the {@link Specification#getDisplayName()} is used while presenting the |
148 |
* Java SDK to the user. |
149 |
* @return the user friendly name, e.g. "Java SE" for "j2se" SDK. |
150 |
* @since 1.26 |
151 |
*/ |
152 |
@NonNull |
153 |
public String getDisplayName() { |
154 |
return displayName != null ? |
155 |
displayName: |
156 |
getName().toUpperCase(Locale.ENGLISH); |
157 |
} |
102 |
|
158 |
|
|
|
159 |
@Override |
103 |
public int hashCode () { |
160 |
public int hashCode () { |
104 |
int hc = 0; |
161 |
int hc = 0; |
105 |
if (this.name != null) |
162 |
if (this.name != null) |
Lines 109-114
Link Here
|
109 |
return hc; |
166 |
return hc; |
110 |
} |
167 |
} |
111 |
|
168 |
|
|
|
169 |
@Override |
112 |
public boolean equals (Object other) { |
170 |
public boolean equals (Object other) { |
113 |
if (other instanceof Specification) { |
171 |
if (other instanceof Specification) { |
114 |
Specification os = (Specification) other; |
172 |
Specification os = (Specification) other; |
Lines 126-131
Link Here
|
126 |
return false; |
184 |
return false; |
127 |
} |
185 |
} |
128 |
|
186 |
|
|
|
187 |
@Override |
129 |
public String toString () { |
188 |
public String toString () { |
130 |
String str = this.name == null ? "" : this.name + " "; // NOI18N |
189 |
String str = this.name == null ? "" : this.name + " "; // NOI18N |
131 |
str += this.version == null ? "" : this.version + " "; // NOI18N |
190 |
str += this.version == null ? "" : this.version + " "; // NOI18N |