All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.rekognition.model.ComparedSourceImageFace Maven / Gradle / Ivy

/*
 * Copyright 2014-2019 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 software.amazon.awssdk.services.rekognition.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Type that describes the face Amazon Rekognition chose to compare with the faces in the target. This contains a * bounding box for the selected face and confidence level that the bounding box contains a face. Note that Amazon * Rekognition selects the largest face in the source image for this comparison. *

*/ @Generated("software.amazon.awssdk:codegen") public final class ComparedSourceImageFace implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField BOUNDING_BOX_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .getter(getter(ComparedSourceImageFace::boundingBox)).setter(setter(Builder::boundingBox)) .constructor(BoundingBox::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BoundingBox").build()).build(); private static final SdkField CONFIDENCE_FIELD = SdkField. builder(MarshallingType.FLOAT) .getter(getter(ComparedSourceImageFace::confidence)).setter(setter(Builder::confidence)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Confidence").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BOUNDING_BOX_FIELD, CONFIDENCE_FIELD)); private static final long serialVersionUID = 1L; private final BoundingBox boundingBox; private final Float confidence; private ComparedSourceImageFace(BuilderImpl builder) { this.boundingBox = builder.boundingBox; this.confidence = builder.confidence; } /** *

* Bounding box of the face. *

* * @return Bounding box of the face. */ public BoundingBox boundingBox() { return boundingBox; } /** *

* Confidence level that the selected bounding box contains a face. *

* * @return Confidence level that the selected bounding box contains a face. */ public Float confidence() { return confidence; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(boundingBox()); hashCode = 31 * hashCode + Objects.hashCode(confidence()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof ComparedSourceImageFace)) { return false; } ComparedSourceImageFace other = (ComparedSourceImageFace) obj; return Objects.equals(boundingBox(), other.boundingBox()) && Objects.equals(confidence(), other.confidence()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public String toString() { return ToString.builder("ComparedSourceImageFace").add("BoundingBox", boundingBox()).add("Confidence", confidence()) .build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "BoundingBox": return Optional.ofNullable(clazz.cast(boundingBox())); case "Confidence": return Optional.ofNullable(clazz.cast(confidence())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((ComparedSourceImageFace) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* Bounding box of the face. *

* * @param boundingBox * Bounding box of the face. * @return Returns a reference to this object so that method calls can be chained together. */ Builder boundingBox(BoundingBox boundingBox); /** *

* Bounding box of the face. *

* This is a convenience that creates an instance of the {@link BoundingBox.Builder} avoiding the need to create * one manually via {@link BoundingBox#builder()}. * * When the {@link Consumer} completes, {@link BoundingBox.Builder#build()} is called immediately and its result * is passed to {@link #boundingBox(BoundingBox)}. * * @param boundingBox * a consumer that will call methods on {@link BoundingBox.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #boundingBox(BoundingBox) */ default Builder boundingBox(Consumer boundingBox) { return boundingBox(BoundingBox.builder().applyMutation(boundingBox).build()); } /** *

* Confidence level that the selected bounding box contains a face. *

* * @param confidence * Confidence level that the selected bounding box contains a face. * @return Returns a reference to this object so that method calls can be chained together. */ Builder confidence(Float confidence); } static final class BuilderImpl implements Builder { private BoundingBox boundingBox; private Float confidence; private BuilderImpl() { } private BuilderImpl(ComparedSourceImageFace model) { boundingBox(model.boundingBox); confidence(model.confidence); } public final BoundingBox.Builder getBoundingBox() { return boundingBox != null ? boundingBox.toBuilder() : null; } @Override public final Builder boundingBox(BoundingBox boundingBox) { this.boundingBox = boundingBox; return this; } public final void setBoundingBox(BoundingBox.BuilderImpl boundingBox) { this.boundingBox = boundingBox != null ? boundingBox.build() : null; } public final Float getConfidence() { return confidence; } @Override public final Builder confidence(Float confidence) { this.confidence = confidence; return this; } public final void setConfidence(Float confidence) { this.confidence = confidence; } @Override public ComparedSourceImageFace build() { return new ComparedSourceImageFace(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy