Solution for Magic Number issue…?
问题 Consider the following code segment... public static UserStatus getEnum(int code) { switch (code) { case 0: return PENDING; case 1: return ACTIVE; case 2: return SUSPENDED; case 3: return DELETED; case 4: return LOGIN_DISABLED; default: return null; } } Now number 3 and 4 in cases(case 3 and case 4) are detected as magic numbers by SONAR. To avoid that issue I changed my code segment as follows... public static UserStatus getEnum(int code) { final int Pending=0; final int Active=1; final int