software.amazon.awssdk.services.appstream.model.ImageStateChangeReason Maven / Gradle / Ivy
/*
* Copyright 2013-2018 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.appstream.model;
import java.util.Objects;
import java.util.Optional;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.protocol.ProtocolMarshaller;
import software.amazon.awssdk.core.protocol.StructuredPojo;
import software.amazon.awssdk.services.appstream.transform.ImageStateChangeReasonMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Describes the reason why the last image state change occurred.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ImageStateChangeReason implements StructuredPojo,
ToCopyableBuilder {
private final String code;
private final String message;
private ImageStateChangeReason(BuilderImpl builder) {
this.code = builder.code;
this.message = builder.message;
}
/**
*
* The state change reason code.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #code} will return
* {@link ImageStateChangeReasonCode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #codeAsString}.
*
*
* @return The state change reason code.
* @see ImageStateChangeReasonCode
*/
public ImageStateChangeReasonCode code() {
return ImageStateChangeReasonCode.fromValue(code);
}
/**
*
* The state change reason code.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #code} will return
* {@link ImageStateChangeReasonCode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #codeAsString}.
*
*
* @return The state change reason code.
* @see ImageStateChangeReasonCode
*/
public String codeAsString() {
return code;
}
/**
*
* The state change reason message.
*
*
* @return The state change reason message.
*/
public String message() {
return message;
}
@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(codeAsString());
hashCode = 31 * hashCode + Objects.hashCode(message());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ImageStateChangeReason)) {
return false;
}
ImageStateChangeReason other = (ImageStateChangeReason) obj;
return Objects.equals(codeAsString(), other.codeAsString()) && Objects.equals(message(), other.message());
}
@Override
public String toString() {
return ToString.builder("ImageStateChangeReason").add("Code", codeAsString()).add("Message", message()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Code":
return Optional.ofNullable(clazz.cast(codeAsString()));
case "Message":
return Optional.ofNullable(clazz.cast(message()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
ImageStateChangeReasonMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* The state change reason code.
*
*
* @param code
* The state change reason code.
* @see ImageStateChangeReasonCode
* @return Returns a reference to this object so that method calls can be chained together.
* @see ImageStateChangeReasonCode
*/
Builder code(String code);
/**
*
* The state change reason code.
*
*
* @param code
* The state change reason code.
* @see ImageStateChangeReasonCode
* @return Returns a reference to this object so that method calls can be chained together.
* @see ImageStateChangeReasonCode
*/
Builder code(ImageStateChangeReasonCode code);
/**
*
* The state change reason message.
*
*
* @param message
* The state change reason message.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder message(String message);
}
static final class BuilderImpl implements Builder {
private String code;
private String message;
private BuilderImpl() {
}
private BuilderImpl(ImageStateChangeReason model) {
code(model.code);
message(model.message);
}
public final String getCode() {
return code;
}
@Override
public final Builder code(String code) {
this.code = code;
return this;
}
@Override
public final Builder code(ImageStateChangeReasonCode code) {
this.code(code.toString());
return this;
}
public final void setCode(String code) {
this.code = code;
}
public final String getMessage() {
return message;
}
@Override
public final Builder message(String message) {
this.message = message;
return this;
}
public final void setMessage(String message) {
this.message = message;
}
@Override
public ImageStateChangeReason build() {
return new ImageStateChangeReason(this);
}
}
}