@Test public void testRound$happyPath() throws Exception { assertThat(CharsetPreference.round(0.5001D),equalTo(500)); }
static int round(final double weight) { Preconditions.checkArgument(weight>=0D,"Weight must be greater than or equal to 0 (%s)",weight); Preconditions.checkArgument(weight<=1D,"Weight must be lower than or equal to 1 (%s)",weight); return DoubleMath.roundToInt(weight*MAX_WEIGHT_DOUBLE,RoundingMode.DOWN); }
CharsetPreference implements Comparable<CharsetPreference> { static int round(final double weight) { Preconditions.checkArgument(weight>=0D,"Weight must be greater than or equal to 0 (%s)",weight); Preconditions.checkArgument(weight<=1D,"Weight must be lower than or equal to 1 (%s)",weight); return DoubleMath.roundToInt(weight*MAX_WEIGHT_DOUBLE,RoundingMode.DOWN); } }
CharsetPreference implements Comparable<CharsetPreference> { static int round(final double weight) { Preconditions.checkArgument(weight>=0D,"Weight must be greater than or equal to 0 (%s)",weight); Preconditions.checkArgument(weight<=1D,"Weight must be lower than or equal to 1 (%s)",weight); return DoubleMath.roundToInt(weight*MAX_WEIGHT_DOUBLE,RoundingMode.DOWN); } CharsetPreference(final String charset, final int weight); }
CharsetPreference implements Comparable<CharsetPreference> { static int round(final double weight) { Preconditions.checkArgument(weight>=0D,"Weight must be greater than or equal to 0 (%s)",weight); Preconditions.checkArgument(weight<=1D,"Weight must be lower than or equal to 1 (%s)",weight); return DoubleMath.roundToInt(weight*MAX_WEIGHT_DOUBLE,RoundingMode.DOWN); } CharsetPreference(final String charset, final int weight); String charset(); double weight(); boolean isWildcard(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); @Override int compareTo(final CharsetPreference o); static CharsetPreference valueOf(final String str); static CharsetPreference wildcard(); static CharsetPreference wildcard(final double weight); static CharsetPreference create(final Charset charset); static CharsetPreference create(final Charset charset, final double weight); }
CharsetPreference implements Comparable<CharsetPreference> { static int round(final double weight) { Preconditions.checkArgument(weight>=0D,"Weight must be greater than or equal to 0 (%s)",weight); Preconditions.checkArgument(weight<=1D,"Weight must be lower than or equal to 1 (%s)",weight); return DoubleMath.roundToInt(weight*MAX_WEIGHT_DOUBLE,RoundingMode.DOWN); } CharsetPreference(final String charset, final int weight); String charset(); double weight(); boolean isWildcard(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); @Override int compareTo(final CharsetPreference o); static CharsetPreference valueOf(final String str); static CharsetPreference wildcard(); static CharsetPreference wildcard(final double weight); static CharsetPreference create(final Charset charset); static CharsetPreference create(final Charset charset, final double weight);  }