Ok, so I did some research on constants and how they should be developed and used. For my application, it made sense to have a lot of enumerations that would combine terms related to each other.
The idea is that when developing web services with hundreds of parameters (many of which are used more than once) and methods, I could annotate the use of enumeration values. Before that, there was a huge, disgusting Constants file with redundant and unchanged values.
So here is an enumeration that I would like to use:
package com.company.ws.data.enums;
public enum Methods {
FIND_ACCOUNT_BY_ACCOUNT_NUMBER("accountByNumberRequest");
private String value;
private Methods(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
}
And here is the place I would like to use:
package com.company.ws.data.models;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.company.ws.data.enums.Methods;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = **Methods.FIND_ACCOUNT_BY_ACCOUNT_NUMBER**, namespace = "com.company.ws")
public class AccountByNumberRequest{
}
, , Type mismatch: cannot convert from Methods to String, . , :
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = **Methods.FIND_ACCOUNT_BY_ACCOUNT_NUMBER.getValue()**, namespace = "")
public class AccountByNumberRequest extends RequestByAccount {
}
, : The value for annotation attribute XmlRootElement.name must be a constant expression.
, , ? , ? - , , ? : http://www.javapractices.com/topic/TopicAction.do?Id=1