/* * 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.comprehend.model; import java.io.Serializable; /** *

* Information about the location of items on a document page. *

*

* For additional information, see Geometry in the Amazon Textract API reference. *

*/ public class Geometry implements Serializable { /** *

* An axis-aligned coarse representation of the location of the recognized * item on the document page. *

*/ private BoundingBox boundingBox; /** *

* Within the bounding box, a fine-grained polygon around the recognized * item. *

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

* An axis-aligned coarse representation of the location of the recognized * item on the document page. *

* * @return

* An axis-aligned coarse representation of the location of the * recognized item on the document page. *

*/ public BoundingBox getBoundingBox() { return boundingBox; } /** *

* An axis-aligned coarse representation of the location of the recognized * item on the document page. *

* * @param boundingBox

* An axis-aligned coarse representation of the location of the * recognized item on the document page. *

*/ public void setBoundingBox(BoundingBox boundingBox) { this.boundingBox = boundingBox; } /** *

* An axis-aligned coarse representation of the location of the recognized * item on the document page. *

*

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

* An axis-aligned coarse representation of the location of the * recognized item on the document page. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Geometry withBoundingBox(BoundingBox boundingBox) { this.boundingBox = boundingBox; return this; } /** *

* Within the bounding box, a fine-grained polygon around the recognized * item. *

* * @return

* Within the bounding box, a fine-grained polygon around the * recognized item. *

*/ public java.util.List getPolygon() { return polygon; } /** *

* Within the bounding box, a fine-grained polygon around the recognized * item. *

* * @param polygon

* Within the bounding box, a fine-grained polygon around the * recognized item. *

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

* Within the bounding box, a fine-grained polygon around the recognized * item. *

*

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

* Within the bounding box, a fine-grained polygon around the * recognized item. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Geometry withPolygon(Point... polygon) { if (getPolygon() == null) { this.polygon = new java.util.ArrayList(polygon.length); } for (Point value : polygon) { this.polygon.add(value); } return this; } /** *

* Within the bounding box, a fine-grained polygon around the recognized * item. *

*

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

* Within the bounding box, a fine-grained polygon around the * recognized item. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Geometry withPolygon(java.util.Collection polygon) { setPolygon(polygon); 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 (getBoundingBox() != null) sb.append("BoundingBox: " + getBoundingBox() + ","); if (getPolygon() != null) sb.append("Polygon: " + getPolygon()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getBoundingBox() == null) ? 0 : getBoundingBox().hashCode()); hashCode = prime * hashCode + ((getPolygon() == null) ? 0 : getPolygon().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Geometry == false) return false; Geometry other = (Geometry) obj; if (other.getBoundingBox() == null ^ this.getBoundingBox() == null) return false; if (other.getBoundingBox() != null && other.getBoundingBox().equals(this.getBoundingBox()) == false) return false; if (other.getPolygon() == null ^ this.getPolygon() == null) return false; if (other.getPolygon() != null && other.getPolygon().equals(this.getPolygon()) == false) return false; return true; } }