Loading...
Searching...
No Matches
Building.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.ArrayList;
4import java.util.concurrent.atomic.AtomicBoolean;
5
18public abstract class Building {
30 public abstract ArrayList<Sublocation> getSublocations();
31
43 public abstract int getActiveSublocationId();
44
56 public abstract void setActiveSublocationId(int activeSublocationId);
57
58 private static final class CppProxy extends Building
59 {
60 private final long nativeRef;
61 private final AtomicBoolean destroyed = new AtomicBoolean(false);
62
63 private CppProxy(long nativeRef)
64 {
65 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
66 this.nativeRef = nativeRef;
67 }
68
69 private native void nativeDestroy(long nativeRef);
70 public void _djinni_private_destroy()
71 {
72 boolean destroyed = this.destroyed.getAndSet(true);
73 if (!destroyed) nativeDestroy(this.nativeRef);
74 }
75 protected void finalize() throws java.lang.Throwable
76 {
77 _djinni_private_destroy();
78 super.finalize();
79 }
80
81 // Building methods
82
83 @Override
84 public ArrayList<Sublocation> getSublocations()
85 {
86 assert !this.destroyed.get() : "trying to use a destroyed object";
87 return native_getSublocations(this.nativeRef);
88 }
89 private native ArrayList<Sublocation> native_getSublocations(long _nativeRef);
90
91 @Override
92 public int getActiveSublocationId()
93 {
94 assert !this.destroyed.get() : "trying to use a destroyed object";
95 return native_getActiveSublocationId(this.nativeRef);
96 }
97 private native int native_getActiveSublocationId(long _nativeRef);
98
99 @Override
100 public void setActiveSublocationId(int activeSublocationId)
101 {
102 assert !this.destroyed.get() : "trying to use a destroyed object";
103 native_setActiveSublocationId(this.nativeRef, activeSublocationId);
104 }
105 private native void native_setActiveSublocationId(long _nativeRef, int activeSublocationId);
106 }
107}