diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-10-17 16:00:44 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-10-17 16:00:45 +1300 |
commit | 566e3dcce47604d661909674308262cc7ddd30e1 (patch) | |
tree | 580f9c06d36efe1656e2ef1b76b6c2cab2281786 /src/org/traccar/BaseProtocol.java | |
parent | 7eda7ec149136829911c154a3ed8d71e3825609a (diff) | |
download | traccar-server-566e3dcce47604d661909674308262cc7ddd30e1.tar.gz traccar-server-566e3dcce47604d661909674308262cc7ddd30e1.tar.bz2 traccar-server-566e3dcce47604d661909674308262cc7ddd30e1.zip |
Automatically get protocol name
Diffstat (limited to 'src/org/traccar/BaseProtocol.java')
-rw-r--r-- | src/org/traccar/BaseProtocol.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java index a78143167..6e44b7285 100644 --- a/src/org/traccar/BaseProtocol.java +++ b/src/org/traccar/BaseProtocol.java @@ -34,8 +34,13 @@ public abstract class BaseProtocol implements Protocol { private StringProtocolEncoder textCommandEncoder = null; - public BaseProtocol(String name) { - this.name = name; + public static String nameFromClass(Class<?> clazz) { + String className = clazz.getSimpleName(); + return className.substring(0, className.length() - 8).toLowerCase(); + } + + public BaseProtocol() { + name = nameFromClass(getClass()); } @Override |