diff options
author | Petre Eftime <[email protected]> | 2016-07-05 15:09:21 +0300 |
---|---|---|
committer | Petre Eftime <[email protected]> | 2016-07-05 15:26:20 +0300 |
commit | e25a1b75fe4d7156be2b1dcb728e3e653406ec8c (patch) | |
tree | 7d0b28f5643a58804bcd7ada9ded0b47a2c9fbff | |
parent | a646843cdc94b3a80db29c27928271664412ca00 (diff) |
java: Add hashCode function for BluetoothObjects
Signed-off-by: Petre Eftime <[email protected]>
-rw-r--r-- | java/BluetoothObject.java | 7 | ||||
-rw-r--r-- | java/jni/BluetoothObject.cxx | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/java/BluetoothObject.java b/java/BluetoothObject.java index 9c8a710a..88170571 100644 --- a/java/BluetoothObject.java +++ b/java/BluetoothObject.java @@ -70,4 +70,11 @@ public abstract class BluetoothObject implements Cloneable return false; return operatorEqual((BluetoothObject)obj); } + + protected native String getObjectPath(); + + public int hashCode() { + String objectPath = getObjectPath(); + return objectPath.hashCode(); + } } diff --git a/java/jni/BluetoothObject.cxx b/java/jni/BluetoothObject.cxx index 9c2a8f3c..0f1e3909 100644 --- a/java/jni/BluetoothObject.cxx +++ b/java/jni/BluetoothObject.cxx @@ -61,3 +61,10 @@ jboolean Java_tinyb_BluetoothObject_operatorEqual(JNIEnv *env, jobject obj, jobj return (*obj_b) == (*obj_other); } +jstring Java_tinyb_BluetoothObject_getObjectPath(JNIEnv *env, jobject obj) +{ + BluetoothObject *obj_b = getInstance<BluetoothObject>(env, obj); + + return env->NewStringUTF(obj_b->get_object_path().c_str()); +} + |