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

* Structure containing details about the detected label, including the name, * detected instances, parent labels, and level of confidence. *

*

*

*/ public class Label implements Serializable { /** *

* The name (label) of the object or scene. *

*/ private String name; /** *

* Level of confidence. *

*

* Constraints:
* Length: 0.0 - 100.0
*/ private Float confidence; /** *

* If Label represents an object, Instances * contains the bounding boxes for each instance of the detected object. * Bounding boxes are returned for common object labels such as people, * cars, furniture, apparel or pets. *

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

* The parent labels for a label. The response includes all ancestor labels. *

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

* A list of potential aliases for a given label. *

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

* A list of the categories associated with a given label. *

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

* The name (label) of the object or scene. *

* * @return

* The name (label) of the object or scene. *

*/ public String getName() { return name; } /** *

* The name (label) of the object or scene. *

* * @param name

* The name (label) of the object or scene. *

*/ public void setName(String name) { this.name = name; } /** *

* The name (label) of the object or scene. *

*

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

* The name (label) of the object or scene. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Label withName(String name) { this.name = name; return this; } /** *

* Level of confidence. *

*

* Constraints:
* Length: 0.0 - 100.0
* * @return

* Level of confidence. *

*/ public Float getConfidence() { return confidence; } /** *

* Level of confidence. *

*

* Constraints:
* Length: 0.0 - 100.0
* * @param confidence

* Level of confidence. *

*/ public void setConfidence(Float confidence) { this.confidence = confidence; } /** *

* Level of confidence. *

*

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

* Constraints:
* Length: 0.0 - 100.0
* * @param confidence

* Level of confidence. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Label withConfidence(Float confidence) { this.confidence = confidence; return this; } /** *

* If Label represents an object, Instances * contains the bounding boxes for each instance of the detected object. * Bounding boxes are returned for common object labels such as people, * cars, furniture, apparel or pets. *

* * @return

* If Label represents an object, * Instances contains the bounding boxes for each * instance of the detected object. Bounding boxes are returned for * common object labels such as people, cars, furniture, apparel or * pets. *

*/ public java.util.List getInstances() { return instances; } /** *

* If Label represents an object, Instances * contains the bounding boxes for each instance of the detected object. * Bounding boxes are returned for common object labels such as people, * cars, furniture, apparel or pets. *

* * @param instances

* If Label represents an object, * Instances contains the bounding boxes for each * instance of the detected object. Bounding boxes are returned * for common object labels such as people, cars, furniture, * apparel or pets. *

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

* If Label represents an object, Instances * contains the bounding boxes for each instance of the detected object. * Bounding boxes are returned for common object labels such as people, * cars, furniture, apparel or pets. *

*

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

* If Label represents an object, * Instances contains the bounding boxes for each * instance of the detected object. Bounding boxes are returned * for common object labels such as people, cars, furniture, * apparel or pets. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Label withInstances(Instance... instances) { if (getInstances() == null) { this.instances = new java.util.ArrayList(instances.length); } for (Instance value : instances) { this.instances.add(value); } return this; } /** *

* If Label represents an object, Instances * contains the bounding boxes for each instance of the detected object. * Bounding boxes are returned for common object labels such as people, * cars, furniture, apparel or pets. *

*

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

* If Label represents an object, * Instances contains the bounding boxes for each * instance of the detected object. Bounding boxes are returned * for common object labels such as people, cars, furniture, * apparel or pets. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Label withInstances(java.util.Collection instances) { setInstances(instances); return this; } /** *

* The parent labels for a label. The response includes all ancestor labels. *

* * @return

* The parent labels for a label. The response includes all ancestor * labels. *

*/ public java.util.List getParents() { return parents; } /** *

* The parent labels for a label. The response includes all ancestor labels. *

* * @param parents

* The parent labels for a label. The response includes all * ancestor labels. *

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

* The parent labels for a label. The response includes all ancestor labels. *

*

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

* The parent labels for a label. The response includes all * ancestor labels. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Label withParents(Parent... parents) { if (getParents() == null) { this.parents = new java.util.ArrayList(parents.length); } for (Parent value : parents) { this.parents.add(value); } return this; } /** *

* The parent labels for a label. The response includes all ancestor labels. *

*

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

* The parent labels for a label. The response includes all * ancestor labels. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Label withParents(java.util.Collection parents) { setParents(parents); return this; } /** *

* A list of potential aliases for a given label. *

* * @return

* A list of potential aliases for a given label. *

*/ public java.util.List getAliases() { return aliases; } /** *

* A list of potential aliases for a given label. *

* * @param aliases

* A list of potential aliases for a given label. *

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

* A list of potential aliases for a given label. *

*

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

* A list of potential aliases for a given label. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Label withAliases(LabelAlias... aliases) { if (getAliases() == null) { this.aliases = new java.util.ArrayList(aliases.length); } for (LabelAlias value : aliases) { this.aliases.add(value); } return this; } /** *

* A list of potential aliases for a given label. *

*

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

* A list of potential aliases for a given label. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Label withAliases(java.util.Collection aliases) { setAliases(aliases); return this; } /** *

* A list of the categories associated with a given label. *

* * @return

* A list of the categories associated with a given label. *

*/ public java.util.List getCategories() { return categories; } /** *

* A list of the categories associated with a given label. *

* * @param categories

* A list of the categories associated with a given label. *

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

* A list of the categories associated with a given label. *

*

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

* A list of the categories associated with a given label. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Label withCategories(LabelCategory... categories) { if (getCategories() == null) { this.categories = new java.util.ArrayList(categories.length); } for (LabelCategory value : categories) { this.categories.add(value); } return this; } /** *

* A list of the categories associated with a given label. *

*

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

* A list of the categories associated with a given label. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Label withCategories(java.util.Collection categories) { setCategories(categories); 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 (getName() != null) sb.append("Name: " + getName() + ","); if (getConfidence() != null) sb.append("Confidence: " + getConfidence() + ","); if (getInstances() != null) sb.append("Instances: " + getInstances() + ","); if (getParents() != null) sb.append("Parents: " + getParents() + ","); if (getAliases() != null) sb.append("Aliases: " + getAliases() + ","); if (getCategories() != null) sb.append("Categories: " + getCategories()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getConfidence() == null) ? 0 : getConfidence().hashCode()); hashCode = prime * hashCode + ((getInstances() == null) ? 0 : getInstances().hashCode()); hashCode = prime * hashCode + ((getParents() == null) ? 0 : getParents().hashCode()); hashCode = prime * hashCode + ((getAliases() == null) ? 0 : getAliases().hashCode()); hashCode = prime * hashCode + ((getCategories() == null) ? 0 : getCategories().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Label == false) return false; Label other = (Label) obj; if (other.getName() == null ^ this.getName() == null) return false; if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; if (other.getConfidence() == null ^ this.getConfidence() == null) return false; if (other.getConfidence() != null && other.getConfidence().equals(this.getConfidence()) == false) return false; if (other.getInstances() == null ^ this.getInstances() == null) return false; if (other.getInstances() != null && other.getInstances().equals(this.getInstances()) == false) return false; if (other.getParents() == null ^ this.getParents() == null) return false; if (other.getParents() != null && other.getParents().equals(this.getParents()) == false) return false; if (other.getAliases() == null ^ this.getAliases() == null) return false; if (other.getAliases() != null && other.getAliases().equals(this.getAliases()) == false) return false; if (other.getCategories() == null ^ this.getCategories() == null) return false; if (other.getCategories() != null && other.getCategories().equals(this.getCategories()) == false) return false; return true; } }