@Test(expected = IllegalArgumentException.class) public void valueOf_greenTooHigh() { Color.of(Color.MIN_INTENSITY, Color.MAX_INTENSITY + 1); }
public static Color of(int red, int green) { if (red < MIN_INTENSITY || red > MAX_INTENSITY) { throw new IllegalArgumentException("Invalid red value : " + red + ". Acceptable values are in range [0..3]."); } if (green < MIN_INTENSITY || green > MAX_INTENSITY) { throw new IllegalArgumentException("Invalid green value : " + green + ". Acceptable values are in range [0..3]."); } return CACHE[red][green]; }
Color { public static Color of(int red, int green) { if (red < MIN_INTENSITY || red > MAX_INTENSITY) { throw new IllegalArgumentException("Invalid red value : " + red + ". Acceptable values are in range [0..3]."); } if (green < MIN_INTENSITY || green > MAX_INTENSITY) { throw new IllegalArgumentException("Invalid green value : " + green + ". Acceptable values are in range [0..3]."); } return CACHE[red][green]; } }
Color { public static Color of(int red, int green) { if (red < MIN_INTENSITY || red > MAX_INTENSITY) { throw new IllegalArgumentException("Invalid red value : " + red + ". Acceptable values are in range [0..3]."); } if (green < MIN_INTENSITY || green > MAX_INTENSITY) { throw new IllegalArgumentException("Invalid green value : " + green + ". Acceptable values are in range [0..3]."); } return CACHE[red][green]; } private  Color(int red, int green); }
Color { public static Color of(int red, int green) { if (red < MIN_INTENSITY || red > MAX_INTENSITY) { throw new IllegalArgumentException("Invalid red value : " + red + ". Acceptable values are in range [0..3]."); } if (green < MIN_INTENSITY || green > MAX_INTENSITY) { throw new IllegalArgumentException("Invalid green value : " + green + ". Acceptable values are in range [0..3]."); } return CACHE[red][green]; } private  Color(int red, int green); static Color of(int red, int green); int getRed(); int getGreen(); @Override boolean equals(Object o); @Override int hashCode(); }
Color { public static Color of(int red, int green) { if (red < MIN_INTENSITY || red > MAX_INTENSITY) { throw new IllegalArgumentException("Invalid red value : " + red + ". Acceptable values are in range [0..3]."); } if (green < MIN_INTENSITY || green > MAX_INTENSITY) { throw new IllegalArgumentException("Invalid green value : " + green + ". Acceptable values are in range [0..3]."); } return CACHE[red][green]; } private  Color(int red, int green); static Color of(int red, int green); int getRed(); int getGreen(); @Override boolean equals(Object o); @Override int hashCode(); static final int MIN_INTENSITY; static final int MAX_INTENSITY; static final Color BLACK; static final Color RED; static final Color GREEN; static final Color ORANGE; static final Color AMBER; static final Color YELLOW; }