software.amazon.awssdk.services.dataexchange.model.JobError Maven / Gradle / Ivy
Show all versions of dataexchange Show documentation
/*
* Copyright 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.dataexchange.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;
/**
*
* An error that occurred with the job request.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class JobError implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField CODE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Code")
.getter(getter(JobError::codeAsString)).setter(setter(Builder::code))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Code").build()).build();
private static final SdkField DETAILS_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Details").getter(getter(JobError::details)).setter(setter(Builder::details))
.constructor(Details::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Details").build()).build();
private static final SdkField LIMIT_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LimitName").getter(getter(JobError::limitNameAsString)).setter(setter(Builder::limitName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LimitName").build()).build();
private static final SdkField LIMIT_VALUE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("LimitValue").getter(getter(JobError::limitValue)).setter(setter(Builder::limitValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LimitValue").build()).build();
private static final SdkField MESSAGE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Message")
.getter(getter(JobError::message)).setter(setter(Builder::message))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Message").build()).build();
private static final SdkField RESOURCE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ResourceId").getter(getter(JobError::resourceId)).setter(setter(Builder::resourceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceId").build()).build();
private static final SdkField RESOURCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ResourceType").getter(getter(JobError::resourceTypeAsString)).setter(setter(Builder::resourceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CODE_FIELD, DETAILS_FIELD,
LIMIT_NAME_FIELD, LIMIT_VALUE_FIELD, MESSAGE_FIELD, RESOURCE_ID_FIELD, RESOURCE_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String code;
private final Details details;
private final String limitName;
private final Double limitValue;
private final String message;
private final String resourceId;
private final String resourceType;
private JobError(BuilderImpl builder) {
this.code = builder.code;
this.details = builder.details;
this.limitName = builder.limitName;
this.limitValue = builder.limitValue;
this.message = builder.message;
this.resourceId = builder.resourceId;
this.resourceType = builder.resourceType;
}
/**
*
* The code for the job error.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #code} will return
* {@link Code#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #codeAsString}.
*
*
* @return The code for the job error.
* @see Code
*/
public final Code code() {
return Code.fromValue(code);
}
/**
*
* The code for the job error.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #code} will return
* {@link Code#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #codeAsString}.
*
*
* @return The code for the job error.
* @see Code
*/
public final String codeAsString() {
return code;
}
/**
*
* The details about the job error.
*
*
* @return The details about the job error.
*/
public final Details details() {
return details;
}
/**
*
* The name of the limit that was reached.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #limitName} will
* return {@link JobErrorLimitName#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #limitNameAsString}.
*
*
* @return The name of the limit that was reached.
* @see JobErrorLimitName
*/
public final JobErrorLimitName limitName() {
return JobErrorLimitName.fromValue(limitName);
}
/**
*
* The name of the limit that was reached.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #limitName} will
* return {@link JobErrorLimitName#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #limitNameAsString}.
*
*
* @return The name of the limit that was reached.
* @see JobErrorLimitName
*/
public final String limitNameAsString() {
return limitName;
}
/**
*
* The value of the exceeded limit.
*
*
* @return The value of the exceeded limit.
*/
public final Double limitValue() {
return limitValue;
}
/**
*
* The message related to the job error.
*
*
* @return The message related to the job error.
*/
public final String message() {
return message;
}
/**
*
* The unique identifier for the resource related to the error.
*
*
* @return The unique identifier for the resource related to the error.
*/
public final String resourceId() {
return resourceId;
}
/**
*
* The type of resource related to the error.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #resourceType} will
* return {@link JobErrorResourceTypes#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #resourceTypeAsString}.
*
*
* @return The type of resource related to the error.
* @see JobErrorResourceTypes
*/
public final JobErrorResourceTypes resourceType() {
return JobErrorResourceTypes.fromValue(resourceType);
}
/**
*
* The type of resource related to the error.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #resourceType} will
* return {@link JobErrorResourceTypes#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #resourceTypeAsString}.
*
*
* @return The type of resource related to the error.
* @see JobErrorResourceTypes
*/
public final String resourceTypeAsString() {
return resourceType;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(codeAsString());
hashCode = 31 * hashCode + Objects.hashCode(details());
hashCode = 31 * hashCode + Objects.hashCode(limitNameAsString());
hashCode = 31 * hashCode + Objects.hashCode(limitValue());
hashCode = 31 * hashCode + Objects.hashCode(message());
hashCode = 31 * hashCode + Objects.hashCode(resourceId());
hashCode = 31 * hashCode + Objects.hashCode(resourceTypeAsString());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof JobError)) {
return false;
}
JobError other = (JobError) obj;
return Objects.equals(codeAsString(), other.codeAsString()) && Objects.equals(details(), other.details())
&& Objects.equals(limitNameAsString(), other.limitNameAsString())
&& Objects.equals(limitValue(), other.limitValue()) && Objects.equals(message(), other.message())
&& Objects.equals(resourceId(), other.resourceId())
&& Objects.equals(resourceTypeAsString(), other.resourceTypeAsString());
}
/**
* 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 final String toString() {
return ToString.builder("JobError").add("Code", codeAsString()).add("Details", details())
.add("LimitName", limitNameAsString()).add("LimitValue", limitValue()).add("Message", message())
.add("ResourceId", resourceId()).add("ResourceType", resourceTypeAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Code":
return Optional.ofNullable(clazz.cast(codeAsString()));
case "Details":
return Optional.ofNullable(clazz.cast(details()));
case "LimitName":
return Optional.ofNullable(clazz.cast(limitNameAsString()));
case "LimitValue":
return Optional.ofNullable(clazz.cast(limitValue()));
case "Message":
return Optional.ofNullable(clazz.cast(message()));
case "ResourceId":
return Optional.ofNullable(clazz.cast(resourceId()));
case "ResourceType":
return Optional.ofNullable(clazz.cast(resourceTypeAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function