This is posing a heated debate and I would like to know if there are any problems with this approach.
I have a class which contains nothing but static strings:
public class EventConstants {
public static ID = "1";
public static DOMAIN = "local";
public static final DEVICE = "PC";
public static final SOURCE = "local";
}
Now the reason ID and DOMAIN are not final
is because I have chosen to override them given Spring ConfigurationProperties
. So...
public CustomEventConstanstants extends EventConstants {
@Autowired
private PropertyMapper mapper;
@PostConstruct
public void init() {
ID = (mapper.ID != null) ? mapper.ID : EventConstants.ID
DOMAIN = (mapper.DOMAIN != null) ? mapper.DOMAIN : EventConstants.DOMAIN
}
}
The idea behind this class is the user can simply call one class and use the appropriate constant as configured by a Spring property or not. Example:
object.methodA(CustomEventConstants.ID) // This will return the configured ID or what's in EventConstants
object.methodB(CustomEventConstants.DEVICE)
The argument I'm having is other's believe it is not appropriate for testing since it cannot be appropriately Mocked out.