예제 #1
0
파일: Token.java 프로젝트: okleine/nCoAP
  @Override
  public boolean equals(Object object) {
    if (object == null || (!(object instanceof Token))) return false;

    Token other = (Token) object;
    return Arrays.equals(this.getBytes(), other.getBytes());
  }
예제 #2
0
파일: Token.java 프로젝트: okleine/nCoAP
  @Override
  public int compareTo(Token other) {

    if (other.equals(this)) return 0;

    if (this.getBytes().length < other.getBytes().length) return -1;

    if (this.getBytes().length > other.getBytes().length) return 1;

    return UnsignedLongs.compare(
        Longs.fromByteArray(Bytes.concat(this.getBytes(), new byte[8])),
        Longs.fromByteArray(Bytes.concat(other.getBytes(), new byte[8])));
  }