/* * Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.amazonaws.services.geo.model; import java.io.Serializable; /** *

* A circle on the earth, as defined by a center point and a radius. *

*/ public class Circle implements Serializable { /** *

* A single point geometry, specifying the center of the circle, using WGS 84 * coordinates, in the form [longitude, latitude]. *

*/ private java.util.List center; /** *

* The radius of the circle in meters. Must be greater than zero and no * larger than 100,000 (100 kilometers). *

*/ private Double radius; /** *

* A single point geometry, specifying the center of the circle, using WGS 84 * coordinates, in the form [longitude, latitude]. *

* * @return

* A single point geometry, specifying the center of the circle, * using WGS * 84 coordinates, in the form * [longitude, latitude]. *

*/ public java.util.List getCenter() { return center; } /** *

* A single point geometry, specifying the center of the circle, using WGS 84 * coordinates, in the form [longitude, latitude]. *

* * @param center

* A single point geometry, specifying the center of the circle, * using WGS 84 coordinates, in the form * [longitude, latitude]. *

*/ public void setCenter(java.util.Collection center) { if (center == null) { this.center = null; return; } this.center = new java.util.ArrayList(center); } /** *

* A single point geometry, specifying the center of the circle, using WGS 84 * coordinates, in the form [longitude, latitude]. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param center

* A single point geometry, specifying the center of the circle, * using WGS 84 coordinates, in the form * [longitude, latitude]. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Circle withCenter(Double... center) { if (getCenter() == null) { this.center = new java.util.ArrayList(center.length); } for (Double value : center) { this.center.add(value); } return this; } /** *

* A single point geometry, specifying the center of the circle, using WGS 84 * coordinates, in the form [longitude, latitude]. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param center

* A single point geometry, specifying the center of the circle, * using WGS 84 coordinates, in the form * [longitude, latitude]. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Circle withCenter(java.util.Collection center) { setCenter(center); return this; } /** *

* The radius of the circle in meters. Must be greater than zero and no * larger than 100,000 (100 kilometers). *

* * @return

* The radius of the circle in meters. Must be greater than zero and * no larger than 100,000 (100 kilometers). *

*/ public Double getRadius() { return radius; } /** *

* The radius of the circle in meters. Must be greater than zero and no * larger than 100,000 (100 kilometers). *

* * @param radius

* The radius of the circle in meters. Must be greater than zero * and no larger than 100,000 (100 kilometers). *

*/ public void setRadius(Double radius) { this.radius = radius; } /** *

* The radius of the circle in meters. Must be greater than zero and no * larger than 100,000 (100 kilometers). *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param radius

* The radius of the circle in meters. Must be greater than zero * and no larger than 100,000 (100 kilometers). *

* @return A reference to this updated object so that method calls can be * chained together. */ public Circle withRadius(Double radius) { this.radius = radius; return this; } /** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getCenter() != null) sb.append("Center: " + getCenter() + ","); if (getRadius() != null) sb.append("Radius: " + getRadius()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getCenter() == null) ? 0 : getCenter().hashCode()); hashCode = prime * hashCode + ((getRadius() == null) ? 0 : getRadius().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Circle == false) return false; Circle other = (Circle) obj; if (other.getCenter() == null ^ this.getCenter() == null) return false; if (other.getCenter() != null && other.getCenter().equals(this.getCenter()) == false) return false; if (other.getRadius() == null ^ this.getRadius() == null) return false; if (other.getRadius() != null && other.getRadius().equals(this.getRadius()) == false) return false; return true; } }