package com.akjava.lib.common.graphics;

public class RGBA {
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(alpha);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + blue;
		result = prime * result + green;
		result = prime * result + red;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		RGBA other = (RGBA) obj;
		if (Double.doubleToLongBits(alpha) != Double.doubleToLongBits(other.alpha))
			return false;
		if (blue != other.blue)
			return false;
		if (green != other.green)
			return false;
		if (red != other.red)
			return false;
		return true;
	}
	public RGBA(int red, int green, int blue){
		this(red,green,blue,1);
	}
public RGBA(int red, int green, int blue, double alpha) {
		super();
		this.red = red;
		this.green = green;
		this.blue = blue;
		this.alpha = alpha;
	}
private int red;
public int getRed() {
	return red;
}
public void setRed(int red) {
	this.red = red;
}
public int getGreen() {
	return green;
}
public void setGreen(int green) {
	this.green = green;
}
public int getBlue() {
	return blue;
}
public void setBlue(int blue) {
	this.blue = blue;
}
public double getAlpha() {
	return alpha;
}
public void setAlpha(double alpha) {
	this.alpha = alpha;
}

public String toString(){
	return "rgba("+red+","+green+","+blue+","+alpha+")";
}

private int green;
private int blue;
private double alpha;
}

@@ -32,24 +32,165 @@
 raphics;%0D%0A%0D%0A
+import static com.google.common.base.Preconditions.checkArgument;%0D%0Aimport static com.google.common.base.Preconditions.checkPositionIndex;%0D%0A%0D%0A
 public class
@@ -1123,78 +1123,183 @@
 %0D%0A%09%09
-super();%0D%0A%09%09this.red = red;%0D%0A%09%09this.green = green;%0D%0A%09%09this.blue = blue
+checkArgument(alpha%3E=0 && alpha%3C=1.0);%0D%0A%09%09this.red = checkPositionIndex(red, 255);%0D%0A%09%09this.green = checkPositionIndex(green, 255);%0D%0A%09%09this.blue = checkPositionIndex(blue, 255)
 ;%0D%0A%09
@@ -1425,19 +1425,44 @@
 s.red = 
-red
+checkPositionIndex(red, 255)
 ;%0D%0A%7D%0D%0Apu
@@ -1552,21 +1552,46 @@
 green = 
-green
+checkPositionIndex(green, 255)
 ;%0D%0A%7D%0D%0Apu
@@ -1676,20 +1676,45 @@
 .blue = 
-blue
+checkPositionIndex(blue, 255)
 ;%0D%0A%7D%0D%0Apu

add arg check