@Test public void qualityCannotBeInvalid(@Mocked final ImmutableVariant variant) throws Exception { try { ImmutableAlternative.create(-1.0D,variant); fail("Should not accept invalid quality"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(),equalTo("Quality cannot be negative (-1.0)")); } }
static ImmutableAlternative create(double quality, ImmutableVariant variant) { requireNonNull(variant,"Variant cannot be null"); requireNonNull(quality,"Quality cannot be null"); checkQuality(quality, "Quality"); return new ImmutableAlternative(quality,variant); }
ImmutableAlternative implements Alternative { static ImmutableAlternative create(double quality, ImmutableVariant variant) { requireNonNull(variant,"Variant cannot be null"); requireNonNull(quality,"Quality cannot be null"); checkQuality(quality, "Quality"); return new ImmutableAlternative(quality,variant); } }
ImmutableAlternative implements Alternative { static ImmutableAlternative create(double quality, ImmutableVariant variant) { requireNonNull(variant,"Variant cannot be null"); requireNonNull(quality,"Quality cannot be null"); checkQuality(quality, "Quality"); return new ImmutableAlternative(quality,variant); } private  ImmutableAlternative(final double quality, final ImmutableVariant variant); }
ImmutableAlternative implements Alternative { static ImmutableAlternative create(double quality, ImmutableVariant variant) { requireNonNull(variant,"Variant cannot be null"); requireNonNull(quality,"Quality cannot be null"); checkQuality(quality, "Quality"); return new ImmutableAlternative(quality,variant); } private  ImmutableAlternative(final double quality, final ImmutableVariant variant); @Override double quality(); @Override MediaType type(); @Override CharacterEncoding charset(); @Override Language language(); @Override String toString(); }
ImmutableAlternative implements Alternative { static ImmutableAlternative create(double quality, ImmutableVariant variant) { requireNonNull(variant,"Variant cannot be null"); requireNonNull(quality,"Quality cannot be null"); checkQuality(quality, "Quality"); return new ImmutableAlternative(quality,variant); } private  ImmutableAlternative(final double quality, final ImmutableVariant variant); @Override double quality(); @Override MediaType type(); @Override CharacterEncoding charset(); @Override Language language(); @Override String toString();  }