mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-07-07 05:21:42 -07:00
add PeerRole.fromInt
This commit is contained in:
parent
7c5f256d4a
commit
056cef7292
4 changed files with 36 additions and 29 deletions
|
@ -27,20 +27,45 @@
|
|||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
/**
|
||||
* What trust hierarchy role does this peer have?
|
||||
*
|
||||
* Defined in ZeroTierOne.h as ZT_PeerRole
|
||||
*/
|
||||
public enum PeerRole {
|
||||
|
||||
/**
|
||||
* An ordinary node
|
||||
*/
|
||||
PEER_ROLE_LEAF,
|
||||
PEER_ROLE_LEAF(0),
|
||||
|
||||
/**
|
||||
* moon root
|
||||
*/
|
||||
PEER_ROLE_MOON,
|
||||
PEER_ROLE_MOON(1),
|
||||
|
||||
/**
|
||||
* planetary root
|
||||
*/
|
||||
PEER_ROLE_PLANET
|
||||
}
|
||||
PEER_ROLE_PLANET(2);
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "unused"})
|
||||
private final int id;
|
||||
|
||||
PeerRole(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static PeerRole fromInt(int id) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
return PEER_ROLE_LEAF;
|
||||
case 1:
|
||||
return PEER_ROLE_MOON;
|
||||
case 2:
|
||||
return PEER_ROLE_PLANET;
|
||||
default:
|
||||
throw new RuntimeException("Unhandled value: " + id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue