Skip to content

Commit

Permalink
DeviceRotation response can return long. (#2504)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafe-g authored and lukeis committed Jul 21, 2016
1 parent b22f77a commit 352e5da
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions java/client/src/org/openqa/selenium/DeviceRotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public class DeviceRotation {
* @param z
*/
public DeviceRotation(int x, int y, int z) {
this.validateParameters(x, y, z);
this.x = x;
this.y = y;
this.z = z;
this.validateParameters(this.x, this.y, this.z);
}

/**
Expand All @@ -54,19 +54,21 @@ public DeviceRotation(int x, int y, int z) {
* z : zVal
* @param map
*/
public DeviceRotation(Map<String, Integer> map) {
public DeviceRotation(Map<String, Number> map) {
if (map == null || !map.containsKey("x") || !map.containsKey("y") || !map.containsKey("z")) {
throw new IllegalArgumentException("Could not initialize DeviceRotation with map given: " + map.toString());
}
this.validateParameters(map.get("x"), map.get("y"), map.get("z"));
this.x = map.get("x");
this.y = map.get("y");
this.z = map.get("z");
this.x = map.get("x").intValue();
this.y = map.get("y").intValue();
this.z = map.get("z").intValue();
this.validateParameters(x, y, z);
}

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

Expand Down Expand Up @@ -97,6 +99,21 @@ public int getZ() {
public ImmutableMap<String,Integer> parameters() {
return ImmutableMap.of("x", this.x, "y", this.y, "z", this.z);
}


@Override
public boolean equals(Object o)
{
if (!(o instanceof DeviceRotation)) {
return false;
}
if (o == this) {
return true;
}

DeviceRotation obj = (DeviceRotation)o;
if (obj.getX() != this.getX() || obj.getY() != this.getY() || obj.getZ() != this.getZ()) {
return false;
}
return true;
}
}

0 comments on commit 352e5da

Please sign in to comment.