Skip to content

Commit f63d21f

Browse files
committed
Make private methods static where possible
This avoids an unneeded object reference. Found via error-prone.
1 parent c8ae720 commit f63d21f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

JSONObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,11 +1496,11 @@ && isValidMethodName(method.getName())) {
14961496
}
14971497
}
14981498

1499-
private boolean isValidMethodName(String name) {
1499+
private static boolean isValidMethodName(String name) {
15001500
return !"getClass".equals(name) && !"getDeclaringClass".equals(name);
15011501
}
15021502

1503-
private String getKeyNameFromMethod(Method method) {
1503+
private static String getKeyNameFromMethod(Method method) {
15041504
final int ignoreDepth = getAnnotationDepth(method, JSONPropertyIgnore.class);
15051505
if (ignoreDepth > 0) {
15061506
final int forcedNameDepth = getAnnotationDepth(method, JSONPropertyName.class);

JSONPointer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public JSONPointer(List<String> refTokens) {
186186
this.refTokens = new ArrayList<String>(refTokens);
187187
}
188188

189-
private String unescape(String token) {
189+
private static String unescape(String token) {
190190
return token.replace("~1", "/").replace("~0", "~")
191191
.replace("\\\"", "\"")
192192
.replace("\\\\", "\\");
@@ -228,7 +228,7 @@ public Object queryFrom(Object document) throws JSONPointerException {
228228
* @return the matched object. If no matching item is found a
229229
* @throws JSONPointerException is thrown if the index is out of bounds
230230
*/
231-
private Object readByIndexToken(Object current, String indexToken) throws JSONPointerException {
231+
private static Object readByIndexToken(Object current, String indexToken) throws JSONPointerException {
232232
try {
233233
int index = Integer.parseInt(indexToken);
234234
JSONArray currentArr = (JSONArray) current;
@@ -267,7 +267,7 @@ public String toString() {
267267
* @param token the JSONPointer segment value to be escaped
268268
* @return the escaped value for the token
269269
*/
270-
private String escape(String token) {
270+
private static String escape(String token) {
271271
return token.replace("~", "~0")
272272
.replace("/", "~1")
273273
.replace("\\", "\\\\")

0 commit comments

Comments
 (0)