diff options
Diffstat (limited to 'java/src/com/zerotier/sdk/PeerPhysicalPath.java')
| -rw-r--r-- | java/src/com/zerotier/sdk/PeerPhysicalPath.java | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/java/src/com/zerotier/sdk/PeerPhysicalPath.java b/java/src/com/zerotier/sdk/PeerPhysicalPath.java index 3f9a8612..f6d32642 100644 --- a/java/src/com/zerotier/sdk/PeerPhysicalPath.java +++ b/java/src/com/zerotier/sdk/PeerPhysicalPath.java @@ -31,48 +31,62 @@ import java.net.InetSocketAddress; /** * Physical network path to a peer + * + * Defined in ZeroTierOne.h as ZT_PeerPhysicalPath */ -public final class PeerPhysicalPath { - private InetSocketAddress address; - private long lastSend; - private long lastReceive; - private boolean fixed; - private boolean preferred; +public class PeerPhysicalPath { + + private final InetSocketAddress address; + + private final long lastSend; + + private final long lastReceive; + + private final boolean preferred; + + public PeerPhysicalPath(InetSocketAddress address, long lastSend, long lastReceive, boolean preferred) { + this.address = address; + if (lastSend < 0) { + throw new RuntimeException("lastSend < 0: " + lastSend); + } + this.lastSend = lastSend; + if (lastReceive < 0) { + throw new RuntimeException("lastReceive < 0: " + lastReceive); + } + this.lastReceive = lastReceive; + this.preferred = preferred; + } - private PeerPhysicalPath() {} + @Override + public String toString() { + return "PeerPhysicalPath(" + address + ", " + lastSend + ", " + lastReceive + ", " + preferred + ")"; + } /** * Address of endpoint */ - public final InetSocketAddress address() { + public InetSocketAddress getAddress() { return address; } /** * Time of last send in milliseconds or 0 for never */ - public final long lastSend() { + public long getLastSend() { return lastSend; } /** * Time of last receive in milliseconds or 0 for never */ - public final long lastReceive() { + public long getLastReceive() { return lastReceive; } /** - * Is path fixed? (i.e. not learned, static) - */ - public final boolean isFixed() { - return fixed; - } - - /** * Is path preferred? */ - public final boolean isPreferred() { + public boolean isPreferred() { return preferred; } -}
\ No newline at end of file +} |
