@@ -40,10 +40,10 @@ public class DeviceRotation {
40
40
* @param z
41
41
*/
42
42
public DeviceRotation (int x , int y , int z ) {
43
- this .validateParameters (x , y , z );
44
43
this .x = x ;
45
44
this .y = y ;
46
45
this .z = z ;
46
+ this .validateParameters (this .x , this .y , this .z );
47
47
}
48
48
49
49
/**
@@ -54,19 +54,21 @@ public DeviceRotation(int x, int y, int z) {
54
54
* z : zVal
55
55
* @param map
56
56
*/
57
- public DeviceRotation (Map <String , Integer > map ) {
57
+ public DeviceRotation (Map <String , Number > map ) {
58
58
if (map == null || !map .containsKey ("x" ) || !map .containsKey ("y" ) || !map .containsKey ("z" )) {
59
59
throw new IllegalArgumentException ("Could not initialize DeviceRotation with map given: " + map .toString ());
60
60
}
61
- this .validateParameters ( map . get ( "x" ), map .get ("y" ), map . get ( "z" ) );
62
- this .x = map .get ("x" );
63
- this .y = map .get ("y" );
64
- this .z = map . get ( "z" );
61
+ this .x = map .get ("x" ). intValue ( );
62
+ this .y = map .get ("y" ). intValue ( );
63
+ this .z = map .get ("z" ). intValue ( );
64
+ this .validateParameters ( x , y , z );
65
65
}
66
66
67
67
private void validateParameters (int x , int y , int z ) {
68
68
if (x < 0 || y < 0 || z < 0 ) {
69
69
throw new IllegalArgumentException ("DeviceRotation requires positive axis values: \n x = " + x + "\n y = " + y + "\n z = " + z );
70
+ } else if (x >= 360 || y >= 360 || z >= 360 ) {
71
+ throw new IllegalArgumentException ("DeviceRotation requires positive axis values under 360: \n x = " + x + "\n y = " + y + "\n z = " + z );
70
72
}
71
73
}
72
74
@@ -97,6 +99,21 @@ public int getZ() {
97
99
public ImmutableMap <String ,Integer > parameters () {
98
100
return ImmutableMap .of ("x" , this .x , "y" , this .y , "z" , this .z );
99
101
}
100
-
101
102
103
+ @ Override
104
+ public boolean equals (Object o )
105
+ {
106
+ if (!(o instanceof DeviceRotation )) {
107
+ return false ;
108
+ }
109
+ if (o == this ) {
110
+ return true ;
111
+ }
112
+
113
+ DeviceRotation obj = (DeviceRotation )o ;
114
+ if (obj .getX () != this .getX () || obj .getY () != this .getY () || obj .getZ () != this .getZ ()) {
115
+ return false ;
116
+ }
117
+ return true ;
118
+ }
102
119
}
0 commit comments