Java Code Examples for java.util.concurrent.Delayed#hashCode()

The following examples show how to use java.util.concurrent.Delayed#hashCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DelayFloat.java    From jstarcraft-core with Apache License 2.0 6 votes vote down vote up
@Override
public int compareTo(Delayed that) {
    long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
    long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
    if (thisDelay < thatDelay) {
        return -1;
    }
    if (thisDelay > thatDelay) {
        return 1;
    }
    // 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
    if (this.equals(that)) {
        return 0;
    } else {
        return this.hashCode() - that.hashCode();
    }
}
 
Example 2
Source File: DelayLong.java    From jstarcraft-core with Apache License 2.0 6 votes vote down vote up
@Override
public int compareTo(Delayed that) {
    long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
    long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
    if (thisDelay < thatDelay) {
        return -1;
    }
    if (thisDelay > thatDelay) {
        return 1;
    }
    // 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
    if (this.equals(that)) {
        return 0;
    } else {
        return this.hashCode() - that.hashCode();
    }
}
 
Example 3
Source File: DelayInteger.java    From jstarcraft-core with Apache License 2.0 6 votes vote down vote up
@Override
public int compareTo(Delayed that) {
    long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
    long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
    if (thisDelay < thatDelay) {
        return -1;
    }
    if (thisDelay > thatDelay) {
        return 1;
    }
    // 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
    if (this.equals(that)) {
        return 0;
    } else {
        return this.hashCode() - that.hashCode();
    }
}
 
Example 4
Source File: DelayDouble.java    From jstarcraft-core with Apache License 2.0 6 votes vote down vote up
@Override
public int compareTo(Delayed that) {
    long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
    long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
    if (thisDelay < thatDelay) {
        return -1;
    }
    if (thisDelay > thatDelay) {
        return 1;
    }
    // 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
    if (this.equals(that)) {
        return 0;
    } else {
        return this.hashCode() - that.hashCode();
    }
}
 
Example 5
Source File: DelayElement.java    From jstarcraft-core with Apache License 2.0 6 votes vote down vote up
@Override
public int compareTo(Delayed that) {
    long thisDelay = this.getDelay(TimeUnit.MILLISECONDS);
    long thatDelay = that.getDelay(TimeUnit.MILLISECONDS);
    if (thisDelay < thatDelay) {
        return -1;
    }
    if (thisDelay > thatDelay) {
        return 1;
    }
    // 时间判断无法区分时,执行如下判断(用于维持 compareTo 的使用约束)
    if (this.equals(that)) {
        return 0;
    } else {
        return this.hashCode() - that.hashCode();
    }
}
 
Example 6
Source File: ComparableDelayed.java    From openpojo with Apache License 2.0 5 votes vote down vote up
public int compareTo(Delayed other) {
  if (other == null || this.hashCode() > other.hashCode())
    return 1;
  if (this.hashCode() == other.hashCode())
    return 0;
  return -1;
}