1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

Make private methods static where possible

This avoids an unneeded object reference.  Found via error-prone.
This commit is contained in:
Andrew Gaul 2019-07-26 15:23:31 -07:00
parent c8ae720caf
commit f63d21fd13
2 changed files with 5 additions and 5 deletions

View file

@ -1496,11 +1496,11 @@ public class JSONObject {
} }
} }
private boolean isValidMethodName(String name) { private static boolean isValidMethodName(String name) {
return !"getClass".equals(name) && !"getDeclaringClass".equals(name); return !"getClass".equals(name) && !"getDeclaringClass".equals(name);
} }
private String getKeyNameFromMethod(Method method) { private static String getKeyNameFromMethod(Method method) {
final int ignoreDepth = getAnnotationDepth(method, JSONPropertyIgnore.class); final int ignoreDepth = getAnnotationDepth(method, JSONPropertyIgnore.class);
if (ignoreDepth > 0) { if (ignoreDepth > 0) {
final int forcedNameDepth = getAnnotationDepth(method, JSONPropertyName.class); final int forcedNameDepth = getAnnotationDepth(method, JSONPropertyName.class);

View file

@ -186,7 +186,7 @@ public class JSONPointer {
this.refTokens = new ArrayList<String>(refTokens); this.refTokens = new ArrayList<String>(refTokens);
} }
private String unescape(String token) { private static String unescape(String token) {
return token.replace("~1", "/").replace("~0", "~") return token.replace("~1", "/").replace("~0", "~")
.replace("\\\"", "\"") .replace("\\\"", "\"")
.replace("\\\\", "\\"); .replace("\\\\", "\\");
@ -228,7 +228,7 @@ public class JSONPointer {
* @return the matched object. If no matching item is found a * @return the matched object. If no matching item is found a
* @throws JSONPointerException is thrown if the index is out of bounds * @throws JSONPointerException is thrown if the index is out of bounds
*/ */
private Object readByIndexToken(Object current, String indexToken) throws JSONPointerException { private static Object readByIndexToken(Object current, String indexToken) throws JSONPointerException {
try { try {
int index = Integer.parseInt(indexToken); int index = Integer.parseInt(indexToken);
JSONArray currentArr = (JSONArray) current; JSONArray currentArr = (JSONArray) current;
@ -267,7 +267,7 @@ public class JSONPointer {
* @param token the JSONPointer segment value to be escaped * @param token the JSONPointer segment value to be escaped
* @return the escaped value for the token * @return the escaped value for the token
*/ */
private String escape(String token) { private static String escape(String token) {
return token.replace("~", "~0") return token.replace("~", "~0")
.replace("/", "~1") .replace("/", "~1")
.replace("\\", "\\\\") .replace("\\", "\\\\")