Path: blob/trunk/java/src/org/openqa/selenium/Rectangle.java
1865 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617package org.openqa.selenium;1819import java.util.Map;20import java.util.Objects;21import org.jspecify.annotations.NullMarked;22import org.jspecify.annotations.Nullable;2324@NullMarked25public class Rectangle {2627public final int x;28public final int y;29public final int height;30public final int width;3132public Rectangle(int x, int y, int height, int width) {33this.x = x;34this.y = y;35this.height = height;36this.width = width;37}3839public Rectangle(Point p, Dimension d) {40x = p.x;41y = p.y;42height = d.height;43width = d.width;44}4546public int getX() {47return x;48}4950public int getY() {51return y;52}5354public int getHeight() {55return height;56}5758public int getWidth() {59return width;60}6162public Point getPoint() {63return new Point(x, y);64}6566public Dimension getDimension() {67return new Dimension(width, height);68}6970private Map<String, Object> toJson() {71return Map.of("width", width, "height", height, "x", x, "y", y);72}7374@Override75public boolean equals(@Nullable Object o) {76if (this == o) {77return true;78}79if (o == null || getClass() != o.getClass()) {80return false;81}8283Rectangle rectangle = (Rectangle) o;8485return x == rectangle.x86&& y == rectangle.y87&& height == rectangle.height88&& width == rectangle.width;89}9091@Override92public int hashCode() {93return Objects.hash(x, y, height, width);94}95}969798