@Override public int compareTo(FrameBytes that) { // FrameBytes may have or not have a related stream (for example, PING do not have a related // stream) // FrameBytes without related streams have higher priority IStream thisStream = getStream(); IStream thatStream = that.getStream(); if (thisStream == null) return thatStream == null ? 0 : -1; if (thatStream == null) return 1; // If this.stream.priority > that.stream.priority => this.stream has less priority than // that.stream return thatStream.getPriority() - thisStream.getPriority(); }