View Javadoc

1   package net.sf.josceleton.core.impl.entity;
2   
3   import net.sf.josceleton.core.api.entity.Coordinate;
4   
5   import com.google.inject.Inject;
6   import com.google.inject.assistedinject.Assisted;
7   
8   class CoordinateImpl implements Coordinate {
9   	
10  	private final float x;
11  	
12  	private final float y;
13  	
14  	private final float z;
15  	
16  	
17  	@Inject CoordinateImpl(
18  			@Assisted("x") final float x,
19  			@Assisted("y") final float y,
20  			@Assisted("z") final float z) {
21  //		if((x >= 0.0 && x <= 1.0) == false) { throw new InvalidArgumentException("x", x, "x >= 0.0 && x <= 1.0"); }
22  		this.x = x;
23  		// MINOR ??? COORDINATE-RANGE y can be > 1.0... other coordinates as well
24  //		if((y >= 0.0 && y <= 1.0) == false) { throw new InvalidArgumentException("y", y, "y >= 0.0 && y <= 1.0"); }
25  		this.y = y;
26  //		if((z >= 0.0 && z <= 7.0) == false) { throw new InvalidArgumentException("z", z, "z >= 0.0 && z <= 1.0"); }
27  		this.z = z;
28  	}
29  	
30  	/** {@inheritDoc} from {@link Coordinate} */
31  	@Override public final float x() { return this.x; }
32  	
33  	/** {@inheritDoc} from {@link Coordinate} */
34  	@Override public final float y() { return this.y; }
35  	
36  	/** {@inheritDoc} from {@link Coordinate} */
37  	@Override public final float z() { return this.z; }
38  	
39  
40  	@Override public final boolean equals(final Object other) {
41  		if(this == other) { return true; }
42  		if((other instanceof Coordinate) == false) {
43  			return false;
44  		}
45  		final Coordinate that = (Coordinate) other;
46  		return this.x() == that.x() && this.y() == that.y() && this.z() == that.z();
47  	}
48  	
49  	@Override public final int hashCode() {
50  		return Float.valueOf(this.x).hashCode();
51  	}
52  	
53  	@Override public final String toString() {
54  		return "CoordinateImpl[x=" + this.x + ", y=" + this.y + ", z=" + this.z + "]";
55  	}
56  }