Loading...
Searching...
No Matches
GraphEdge.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
16public abstract class GraphEdge {
30 public abstract Float getWeight();
31
45 public abstract int getDst();
46
60 public abstract int getSrc();
61
75 public abstract Float getWeightCoef();
76
77 private static final class CppProxy extends GraphEdge
78 {
79 private final long nativeRef;
80 private final AtomicBoolean destroyed = new AtomicBoolean(false);
81
82 private CppProxy(long nativeRef)
83 {
84 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
85 this.nativeRef = nativeRef;
86 }
87
88 private native void nativeDestroy(long nativeRef);
89 public void _djinni_private_destroy()
90 {
91 boolean destroyed = this.destroyed.getAndSet(true);
92 if (!destroyed) nativeDestroy(this.nativeRef);
93 }
94 protected void finalize() throws java.lang.Throwable
95 {
96 _djinni_private_destroy();
97 super.finalize();
98 }
99
100 // GraphEdge methods
101
102 @Override
103 public Float getWeight()
104 {
105 assert !this.destroyed.get() : "trying to use a destroyed object";
106 return native_getWeight(this.nativeRef);
107 }
108 private native Float native_getWeight(long _nativeRef);
109
110 @Override
111 public int getDst()
112 {
113 assert !this.destroyed.get() : "trying to use a destroyed object";
114 return native_getDst(this.nativeRef);
115 }
116 private native int native_getDst(long _nativeRef);
117
118 @Override
119 public int getSrc()
120 {
121 assert !this.destroyed.get() : "trying to use a destroyed object";
122 return native_getSrc(this.nativeRef);
123 }
124 private native int native_getSrc(long _nativeRef);
125
126 @Override
127 public Float getWeightCoef()
128 {
129 assert !this.destroyed.get() : "trying to use a destroyed object";
130 return native_getWeightCoef(this.nativeRef);
131 }
132 private native Float native_getWeightCoef(long _nativeRef);
133 }
134}