17
17
18
18
package org .openqa .selenium ;
19
19
20
+ import java .util .Collections ;
21
+ import java .util .HashMap ;
20
22
import java .util .Map ;
21
- import com .google .common .collect .ImmutableMap ;
22
23
23
24
/**
24
25
* Defines an object which represents the three dimensional plane and how a device can be rotated about it.
25
26
* Each of the axis is in positive degrees on the real number scale (0 <= deg <= 360).
26
- *
27
+ *
27
28
* Example Instantiation to rotate device to "Landscape Right":
28
29
* DeviceRotation(0, 0, 90);
29
30
*/
@@ -43,11 +44,11 @@ public DeviceRotation(int x, int y, int z) {
43
44
this .x = x ;
44
45
this .y = y ;
45
46
this .z = z ;
46
- this .validateParameters (this .x , this .y , this .z );
47
+ this .validateParameters (this .x , this .y , this .z );
47
48
}
48
-
49
+
49
50
/**
50
- * Instantiate a DeviceRotation object based on a
51
+ * Instantiate a DeviceRotation object based on a
51
52
* HashMap object where the keys are the axis x, y, and z respectively:
52
53
* x : xVal
53
54
* y : yVal
@@ -63,15 +64,15 @@ public DeviceRotation(Map<String, Number> map) {
63
64
this .z = map .get ("z" ).intValue ();
64
65
this .validateParameters (x , y , z );
65
66
}
66
-
67
+
67
68
private void validateParameters (int x , int y , int z ) {
68
69
if (x < 0 || y < 0 || z < 0 ) {
69
70
throw new IllegalArgumentException ("DeviceRotation requires positive axis values: \n x = " + x + "\n y = " + y + "\n z = " + z );
70
71
} else if (x >= 360 || y >= 360 || z >= 360 ) {
71
72
throw new IllegalArgumentException ("DeviceRotation requires positive axis values under 360: \n x = " + x + "\n y = " + y + "\n z = " + z );
72
73
}
73
74
}
74
-
75
+
75
76
/**
76
77
* @return the x
77
78
*/
@@ -94,22 +95,26 @@ public int getZ() {
94
95
}
95
96
96
97
/**
97
- * @return returns all axis mapped to an ImmutableMap
98
+ * @return returns all axis mapped to a Map
98
99
*/
99
- public ImmutableMap <String ,Integer > parameters () {
100
- return ImmutableMap .of ("x" , this .x , "y" , this .y , "z" , this .z );
100
+ public Map <String ,Integer > parameters () {
101
+ HashMap <String , Integer > values = new HashMap <>();
102
+ values .put ("x" , this .x );
103
+ values .put ("y" , this .y );
104
+ values .put ("z" , this .z );
105
+ return Collections .unmodifiableMap (values );
101
106
}
102
-
107
+
103
108
@ Override
104
- public boolean equals (Object o )
109
+ public boolean equals (Object o )
105
110
{
106
111
if (!(o instanceof DeviceRotation )) {
107
112
return false ;
108
113
}
109
114
if (o == this ) {
110
115
return true ;
111
116
}
112
-
117
+
113
118
DeviceRotation obj = (DeviceRotation )o ;
114
119
if (obj .getX () != this .getX () || obj .getY () != this .getY () || obj .getZ () != this .getZ ()) {
115
120
return false ;
0 commit comments