@Override public int compareTo(final MediaType that) { requireNonNull(that, "A media type is required."); if (this == that) { return 0; } if (this.wildcardType && !that.wildcardType) { return 1; } if (that.wildcardType && !this.wildcardType) { return -1; } if (this.wildcardSubtype && !that.wildcardSubtype) { return 1; } if (that.wildcardSubtype && !this.wildcardSubtype) { return -1; } if (!this.type().equals(that.type())) { return 0; } int q = Float.compare(that.quality(), this.quality()); if (q != 0) { return q; } // param size int paramsSize1 = this.params.size(); int paramsSize2 = that.params.size(); return (paramsSize2 < paramsSize1 ? -1 : (paramsSize2 == paramsSize1 ? 0 : 1)); }
@Override public int compareTo(final MediaType that) { requireNonNull(that, "A media type is required."); if (this == that) { return 0; } if (this.wildcardType && !that.wildcardType) { return 1; } if (that.wildcardType && !this.wildcardType) { return -1; } if (this.wildcardSubtype && !that.wildcardSubtype) { return 1; } if (that.wildcardSubtype && !this.wildcardSubtype) { return -1; } if (!this.type().equals(that.type())) { return 0; } int q = Float.compare(that.quality(), this.quality()); if (q != 0) { return q; } // param size int paramsSize1 = this.params.size(); int paramsSize2 = that.params.size(); return (paramsSize2 < paramsSize1 ? -1 : (paramsSize2 == paramsSize1 ? 0 : 1)); }