Reputation: 1198
Easy
public enum AvailableTestServices {
UserContext("userContext", ["userURI"]), Level0and1ForUser("level0and1ForUser", ["userURI"]);
private String serviceName;
private String[] requiredParameters;
private AvailableTestServices(String serviceName,
String[] requriedParameters) {
this.serviceName = serviceName;
this.requiredParameters = requriedParameters;
}
public String getValue() {
return serviceName;
}
public String[] getRequiredParameters(){
return this.requiredParameters;
}
}
I get an exception on the ,
that is in :
UserContext("userContext", ["userURI"]), Level0and1ForUser("level0and1ForUser", ["userURI"]);
the error is:
Syntax error on token ",", Expression expected after this token AvailableTestServices.java /
Upvotes: 0
Views: 150
Reputation: 4202
The proper way to do it should be the following:
UserContext("userContext", new String[]{"userURI"}),
Level0and1ForUser("level0and1ForUser", new String[]{"userURI"});
Upvotes: 2
Reputation: 3956
There is no syntax like this ["Text"]
for creating an array. This is the correct way:
public enum AvailableTestServices {
UserContext("userContext", new String[] { "userURI" }), Level0and1ForUser("level0and1ForUser",
new String[] { "userURI" });
private String serviceName;
private String[] requiredParameters;
private AvailableTestServices(String serviceName, String[] requriedParameters) {
this.serviceName = serviceName;
this.requiredParameters = requriedParameters;
}
public String getValue() {
return serviceName;
}
public String[] getRequiredParameters() {
return this.requiredParameters;
}
}
Upvotes: 2