Skip to content

Commit 352e5da

Browse files
rafe-glukeis
authored andcommitted
DeviceRotation response can return long. (#2504)
1 parent b22f77a commit 352e5da

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

java/client/src/org/openqa/selenium/DeviceRotation.java

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public class DeviceRotation {
4040
* @param z
4141
*/
4242
public DeviceRotation(int x, int y, int z) {
43-
this.validateParameters(x, y, z);
4443
this.x = x;
4544
this.y = y;
4645
this.z = z;
46+
this.validateParameters(this.x, this.y, this.z);
4747
}
4848

4949
/**
@@ -54,19 +54,21 @@ public DeviceRotation(int x, int y, int z) {
5454
* z : zVal
5555
* @param map
5656
*/
57-
public DeviceRotation(Map<String, Integer> map) {
57+
public DeviceRotation(Map<String, Number> map) {
5858
if (map == null || !map.containsKey("x") || !map.containsKey("y") || !map.containsKey("z")) {
5959
throw new IllegalArgumentException("Could not initialize DeviceRotation with map given: " + map.toString());
6060
}
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);
6565
}
6666

6767
private void validateParameters(int x, int y, int z) {
6868
if (x < 0 || y < 0 || z < 0) {
6969
throw new IllegalArgumentException("DeviceRotation requires positive axis values: \nx = " + x + "\ny = " + y + "\nz = " + z);
70+
} else if (x >= 360 || y >= 360 || z >= 360) {
71+
throw new IllegalArgumentException("DeviceRotation requires positive axis values under 360: \nx = " + x + "\ny = " + y + "\nz = " + z);
7072
}
7173
}
7274

@@ -97,6 +99,21 @@ public int getZ() {
9799
public ImmutableMap<String,Integer> parameters() {
98100
return ImmutableMap.of("x", this.x, "y", this.y, "z", this.z);
99101
}
100-
101102

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+
}
102119
}

0 commit comments

Comments
 (0)