I've used following code in my project. When I evaluated it using sonar it shows Unused private method
violation for the private constructor defined in ObjectTypes
inner class. If I removed ObjectTypes
constructor it shows Hide Utility Class Constructor
violation. Please help me to find the best possible way to overcome this issue.
public final class Constants
{
private Constants()
{
}
public static final String KEY_SEPARATOR = " ~ ";
public static final String COMMON_SEPARATOR = " : ";
public final class ObjectTypes
{
private ObjectTypes()
{
}
public static final String ACTION_CODES = "Action Codes";
public static final String ALL_ACTION_CODES = "All Action Codes";
//more lines
}
}
This is the problem:
private Constants()
{
}
And this:
private ObjectTypes()
{
}
You do not have to declare EMPTY constructors.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.