
software.amazon.awssdk.services.rekognition.model.DetectFacesResponse 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.util.Arrays;
import java.util.Collection;
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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class DetectFacesResponse extends RekognitionResponse implements
ToCopyableBuilder {
private static final SdkField> FACE_DETAILS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(DetectFacesResponse::faceDetails))
.setter(setter(Builder::faceDetails))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FaceDetails").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(FaceDetail::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField ORIENTATION_CORRECTION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(DetectFacesResponse::orientationCorrectionAsString)).setter(setter(Builder::orientationCorrection))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OrientationCorrection").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FACE_DETAILS_FIELD,
ORIENTATION_CORRECTION_FIELD));
private final List faceDetails;
private final String orientationCorrection;
private DetectFacesResponse(BuilderImpl builder) {
super(builder);
this.faceDetails = builder.faceDetails;
this.orientationCorrection = builder.orientationCorrection;
}
/**
*
* Details of each face found in the image.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Details of each face found in the image.
*/
public List faceDetails() {
return faceDetails;
}
/**
*
* The value of OrientationCorrection
is always null.
*
*
* If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata that
* includes the image's orientation. Amazon Rekognition uses this orientation information to perform image
* correction. The bounding box coordinates are translated to represent object locations after the orientation
* information in the Exif metadata is used to correct the image orientation. Images in .png format don't contain
* Exif metadata.
*
*
* Amazon Rekognition doesn’t perform image correction for images in .png format and .jpeg images without
* orientation information in the image Exif metadata. The bounding box coordinates aren't translated and represent
* the object locations before the image is rotated.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #orientationCorrection} will return {@link OrientationCorrection#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #orientationCorrectionAsString}.
*
*
* @return The value of OrientationCorrection
is always null.
*
* If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata
* that includes the image's orientation. Amazon Rekognition uses this orientation information to perform
* image correction. The bounding box coordinates are translated to represent object locations after the
* orientation information in the Exif metadata is used to correct the image orientation. Images in .png
* format don't contain Exif metadata.
*
*
* Amazon Rekognition doesn’t perform image correction for images in .png format and .jpeg images without
* orientation information in the image Exif metadata. The bounding box coordinates aren't translated and
* represent the object locations before the image is rotated.
* @see OrientationCorrection
*/
public OrientationCorrection orientationCorrection() {
return OrientationCorrection.fromValue(orientationCorrection);
}
/**
*
* The value of OrientationCorrection
is always null.
*
*
* If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata that
* includes the image's orientation. Amazon Rekognition uses this orientation information to perform image
* correction. The bounding box coordinates are translated to represent object locations after the orientation
* information in the Exif metadata is used to correct the image orientation. Images in .png format don't contain
* Exif metadata.
*
*
* Amazon Rekognition doesn’t perform image correction for images in .png format and .jpeg images without
* orientation information in the image Exif metadata. The bounding box coordinates aren't translated and represent
* the object locations before the image is rotated.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #orientationCorrection} will return {@link OrientationCorrection#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #orientationCorrectionAsString}.
*
*
* @return The value of OrientationCorrection
is always null.
*
* If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata
* that includes the image's orientation. Amazon Rekognition uses this orientation information to perform
* image correction. The bounding box coordinates are translated to represent object locations after the
* orientation information in the Exif metadata is used to correct the image orientation. Images in .png
* format don't contain Exif metadata.
*
*
* Amazon Rekognition doesn’t perform image correction for images in .png format and .jpeg images without
* orientation information in the image Exif metadata. The bounding box coordinates aren't translated and
* represent the object locations before the image is rotated.
* @see OrientationCorrection
*/
public String orientationCorrectionAsString() {
return orientationCorrection;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(faceDetails());
hashCode = 31 * hashCode + Objects.hashCode(orientationCorrectionAsString());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DetectFacesResponse)) {
return false;
}
DetectFacesResponse other = (DetectFacesResponse) obj;
return Objects.equals(faceDetails(), other.faceDetails())
&& Objects.equals(orientationCorrectionAsString(), other.orientationCorrectionAsString());
}
/**
* 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("DetectFacesResponse").add("FaceDetails", faceDetails())
.add("OrientationCorrection", orientationCorrectionAsString()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "FaceDetails":
return Optional.ofNullable(clazz.cast(faceDetails()));
case "OrientationCorrection":
return Optional.ofNullable(clazz.cast(orientationCorrectionAsString()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata
* that includes the image's orientation. Amazon Rekognition uses this orientation information to perform
* image correction. The bounding box coordinates are translated to represent object locations after the
* orientation information in the Exif metadata is used to correct the image orientation. Images in .png
* format don't contain Exif metadata.
*
*
* Amazon Rekognition doesn’t perform image correction for images in .png format and .jpeg images without
* orientation information in the image Exif metadata. The bounding box coordinates aren't translated and
* represent the object locations before the image is rotated.
* @see OrientationCorrection
* @return Returns a reference to this object so that method calls can be chained together.
* @see OrientationCorrection
*/
Builder orientationCorrection(String orientationCorrection);
/**
*
* The value of OrientationCorrection
is always null.
*
*
* If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata that
* includes the image's orientation. Amazon Rekognition uses this orientation information to perform image
* correction. The bounding box coordinates are translated to represent object locations after the orientation
* information in the Exif metadata is used to correct the image orientation. Images in .png format don't
* contain Exif metadata.
*
*
* Amazon Rekognition doesn’t perform image correction for images in .png format and .jpeg images without
* orientation information in the image Exif metadata. The bounding box coordinates aren't translated and
* represent the object locations before the image is rotated.
*
*
* @param orientationCorrection
* The value of OrientationCorrection
is always null.
*
* If the input image is in .jpeg format, it might contain exchangeable image file format (Exif) metadata
* that includes the image's orientation. Amazon Rekognition uses this orientation information to perform
* image correction. The bounding box coordinates are translated to represent object locations after the
* orientation information in the Exif metadata is used to correct the image orientation. Images in .png
* format don't contain Exif metadata.
*
*
* Amazon Rekognition doesn’t perform image correction for images in .png format and .jpeg images without
* orientation information in the image Exif metadata. The bounding box coordinates aren't translated and
* represent the object locations before the image is rotated.
* @see OrientationCorrection
* @return Returns a reference to this object so that method calls can be chained together.
* @see OrientationCorrection
*/
Builder orientationCorrection(OrientationCorrection orientationCorrection);
}
static final class BuilderImpl extends RekognitionResponse.BuilderImpl implements Builder {
private List faceDetails = DefaultSdkAutoConstructList.getInstance();
private String orientationCorrection;
private BuilderImpl() {
}
private BuilderImpl(DetectFacesResponse model) {
super(model);
faceDetails(model.faceDetails);
orientationCorrection(model.orientationCorrection);
}
public final Collection getFaceDetails() {
return faceDetails != null ? faceDetails.stream().map(FaceDetail::toBuilder).collect(Collectors.toList()) : null;
}
@Override
public final Builder faceDetails(Collection faceDetails) {
this.faceDetails = FaceDetailListCopier.copy(faceDetails);
return this;
}
@Override
@SafeVarargs
public final Builder faceDetails(FaceDetail... faceDetails) {
faceDetails(Arrays.asList(faceDetails));
return this;
}
@Override
@SafeVarargs
public final Builder faceDetails(Consumer... faceDetails) {
faceDetails(Stream.of(faceDetails).map(c -> FaceDetail.builder().applyMutation(c).build())
.collect(Collectors.toList()));
return this;
}
public final void setFaceDetails(Collection faceDetails) {
this.faceDetails = FaceDetailListCopier.copyFromBuilder(faceDetails);
}
public final String getOrientationCorrectionAsString() {
return orientationCorrection;
}
@Override
public final Builder orientationCorrection(String orientationCorrection) {
this.orientationCorrection = orientationCorrection;
return this;
}
@Override
public final Builder orientationCorrection(OrientationCorrection orientationCorrection) {
this.orientationCorrection(orientationCorrection.toString());
return this;
}
public final void setOrientationCorrection(String orientationCorrection) {
this.orientationCorrection = orientationCorrection;
}
@Override
public DetectFacesResponse build() {
return new DetectFacesResponse(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}