diff options
author | Abyss777 <abyss@fox5.ru> | 2017-05-18 15:56:48 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-05-18 15:56:48 +0500 |
commit | 8331091c5bba763fa714f8e8a6dbd8c58136429d (patch) | |
tree | a6c2782fee59256bdf96cbb6abe25499e6f732ff /src/org | |
parent | 660828e48ac0657e9673c1d7647131ffa9d9c963 (diff) | |
download | traccar-server-8331091c5bba763fa714f8e8a6dbd8c58136429d.tar.gz traccar-server-8331091c5bba763fa714f8e8a6dbd8c58136429d.tar.bz2 traccar-server-8331091c5bba763fa714f8e8a6dbd8c58136429d.zip |
- Optimize method enumeration
- Optimize variable name construct
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/processing/ComputedAttributesHandler.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/org/traccar/processing/ComputedAttributesHandler.java b/src/org/traccar/processing/ComputedAttributesHandler.java index b158431ef..8689c5a58 100644 --- a/src/org/traccar/processing/ComputedAttributesHandler.java +++ b/src/org/traccar/processing/ComputedAttributesHandler.java @@ -18,8 +18,11 @@ package org.traccar.processing; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.Arrays; import java.util.Collection; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import org.apache.commons.jexl2.JexlEngine; import org.apache.commons.jexl2.JexlException; @@ -41,11 +44,11 @@ public class ComputedAttributesHandler extends BaseDataHandler { private MapContext prepareContext(Position position) { MapContext result = new MapContext(); - Method[] methods = position.getClass().getMethods(); + Set<Method> methods = new HashSet<>(Arrays.asList(position.getClass().getMethods())); + methods.removeAll(Arrays.asList(Object.class.getMethods())); for (Method method : methods) { - if (method.getName().startsWith("get") && method.getParameterTypes().length == 0 - && !method.getName().equals("getClass")) { - String name = method.getName().substring(3, 4).toLowerCase() + method.getName().substring(4); + if (method.getName().startsWith("get") && method.getParameterTypes().length == 0) { + String name = Character.toLowerCase(method.getName().charAt(3)) + method.getName().substring(4); try { if (!method.getReturnType().equals(Map.class)) { |