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

* Information about how blocks are related to each other. A Block * object contains 0 or more Relation objects in a list, * Relationships. For more information, see Block. *

*

* The Type element provides the type of the relationship for all * blocks in the IDs array. *

*/ public class Relationship implements Serializable { /** *

* The type of relationship between the blocks in the IDs array and the * current block. The following list describes the relationship types that * can be returned. *

* *

* Constraints:
* Allowed Values: VALUE, CHILD, COMPLEX_FEATURES, MERGED_CELL, * TITLE, ANSWER, TABLE, TABLE_TITLE, TABLE_FOOTER */ private String type; /** *

* An array of IDs for related blocks. You can get the type of the * relationship from the Type element. *

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

* The type of relationship between the blocks in the IDs array and the * current block. The following list describes the relationship types that * can be returned. *

* *

* Constraints:
* Allowed Values: VALUE, CHILD, COMPLEX_FEATURES, MERGED_CELL, * TITLE, ANSWER, TABLE, TABLE_TITLE, TABLE_FOOTER * * @return

* The type of relationship between the blocks in the IDs array and * the current block. The following list describes the relationship * types that can be returned. *

* * @see RelationshipType */ public String getType() { return type; } /** *

* The type of relationship between the blocks in the IDs array and the * current block. The following list describes the relationship types that * can be returned. *

* *

* Constraints:
* Allowed Values: VALUE, CHILD, COMPLEX_FEATURES, MERGED_CELL, * TITLE, ANSWER, TABLE, TABLE_TITLE, TABLE_FOOTER * * @param type

* The type of relationship between the blocks in the IDs array * and the current block. The following list describes the * relationship types that can be returned. *

* * @see RelationshipType */ public void setType(String type) { this.type = type; } /** *

* The type of relationship between the blocks in the IDs array and the * current block. The following list describes the relationship types that * can be returned. *

* *

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

* Constraints:
* Allowed Values: VALUE, CHILD, COMPLEX_FEATURES, MERGED_CELL, * TITLE, ANSWER, TABLE, TABLE_TITLE, TABLE_FOOTER * * @param type

* The type of relationship between the blocks in the IDs array * and the current block. The following list describes the * relationship types that can be returned. *

* * @return A reference to this updated object so that method calls can be * chained together. * @see RelationshipType */ public Relationship withType(String type) { this.type = type; return this; } /** *

* The type of relationship between the blocks in the IDs array and the * current block. The following list describes the relationship types that * can be returned. *

* *

* Constraints:
* Allowed Values: VALUE, CHILD, COMPLEX_FEATURES, MERGED_CELL, * TITLE, ANSWER, TABLE, TABLE_TITLE, TABLE_FOOTER * * @param type

* The type of relationship between the blocks in the IDs array * and the current block. The following list describes the * relationship types that can be returned. *

* * @see RelationshipType */ public void setType(RelationshipType type) { this.type = type.toString(); } /** *

* The type of relationship between the blocks in the IDs array and the * current block. The following list describes the relationship types that * can be returned. *

* *

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

* Constraints:
* Allowed Values: VALUE, CHILD, COMPLEX_FEATURES, MERGED_CELL, * TITLE, ANSWER, TABLE, TABLE_TITLE, TABLE_FOOTER * * @param type

* The type of relationship between the blocks in the IDs array * and the current block. The following list describes the * relationship types that can be returned. *

* * @return A reference to this updated object so that method calls can be * chained together. * @see RelationshipType */ public Relationship withType(RelationshipType type) { this.type = type.toString(); return this; } /** *

* An array of IDs for related blocks. You can get the type of the * relationship from the Type element. *

* * @return

* An array of IDs for related blocks. You can get the type of the * relationship from the Type element. *

*/ public java.util.List getIds() { return ids; } /** *

* An array of IDs for related blocks. You can get the type of the * relationship from the Type element. *

* * @param ids

* An array of IDs for related blocks. You can get the type of * the relationship from the Type element. *

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

* An array of IDs for related blocks. You can get the type of the * relationship from the Type element. *

*

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

* An array of IDs for related blocks. You can get the type of * the relationship from the Type element. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Relationship withIds(String... ids) { if (getIds() == null) { this.ids = new java.util.ArrayList(ids.length); } for (String value : ids) { this.ids.add(value); } return this; } /** *

* An array of IDs for related blocks. You can get the type of the * relationship from the Type element. *

*

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

* An array of IDs for related blocks. You can get the type of * the relationship from the Type element. *

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