software.amazon.awssdk.services.ecr.model.Layer Maven / Gradle / Ivy
Show all versions of ecr 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.ecr.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.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 object representing an Amazon ECR image layer.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Layer implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField LAYER_DIGEST_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("layerDigest").getter(getter(Layer::layerDigest)).setter(setter(Builder::layerDigest))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("layerDigest").build()).build();
private static final SdkField LAYER_AVAILABILITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("layerAvailability").getter(getter(Layer::layerAvailabilityAsString))
.setter(setter(Builder::layerAvailability))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("layerAvailability").build()).build();
private static final SdkField LAYER_SIZE_FIELD = SdkField. builder(MarshallingType.LONG).memberName("layerSize")
.getter(getter(Layer::layerSize)).setter(setter(Builder::layerSize))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("layerSize").build()).build();
private static final SdkField MEDIA_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("mediaType").getter(getter(Layer::mediaType)).setter(setter(Builder::mediaType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("mediaType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(LAYER_DIGEST_FIELD,
LAYER_AVAILABILITY_FIELD, LAYER_SIZE_FIELD, MEDIA_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String layerDigest;
private final String layerAvailability;
private final Long layerSize;
private final String mediaType;
private Layer(BuilderImpl builder) {
this.layerDigest = builder.layerDigest;
this.layerAvailability = builder.layerAvailability;
this.layerSize = builder.layerSize;
this.mediaType = builder.mediaType;
}
/**
*
* The sha256
digest of the image layer.
*
*
* @return The sha256
digest of the image layer.
*/
public final String layerDigest() {
return layerDigest;
}
/**
*
* The availability status of the image layer.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #layerAvailability}
* will return {@link LayerAvailability#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #layerAvailabilityAsString}.
*
*
* @return The availability status of the image layer.
* @see LayerAvailability
*/
public final LayerAvailability layerAvailability() {
return LayerAvailability.fromValue(layerAvailability);
}
/**
*
* The availability status of the image layer.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #layerAvailability}
* will return {@link LayerAvailability#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #layerAvailabilityAsString}.
*
*
* @return The availability status of the image layer.
* @see LayerAvailability
*/
public final String layerAvailabilityAsString() {
return layerAvailability;
}
/**
*
* The size, in bytes, of the image layer.
*
*
* @return The size, in bytes, of the image layer.
*/
public final Long layerSize() {
return layerSize;
}
/**
*
* The media type of the layer, such as application/vnd.docker.image.rootfs.diff.tar.gzip
or
* application/vnd.oci.image.layer.v1.tar+gzip
.
*
*
* @return The media type of the layer, such as application/vnd.docker.image.rootfs.diff.tar.gzip
or
* application/vnd.oci.image.layer.v1.tar+gzip
.
*/
public final String mediaType() {
return mediaType;
}
@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(layerDigest());
hashCode = 31 * hashCode + Objects.hashCode(layerAvailabilityAsString());
hashCode = 31 * hashCode + Objects.hashCode(layerSize());
hashCode = 31 * hashCode + Objects.hashCode(mediaType());
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 Layer)) {
return false;
}
Layer other = (Layer) obj;
return Objects.equals(layerDigest(), other.layerDigest())
&& Objects.equals(layerAvailabilityAsString(), other.layerAvailabilityAsString())
&& Objects.equals(layerSize(), other.layerSize()) && Objects.equals(mediaType(), other.mediaType());
}
/**
* 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("Layer").add("LayerDigest", layerDigest()).add("LayerAvailability", layerAvailabilityAsString())
.add("LayerSize", layerSize()).add("MediaType", mediaType()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "layerDigest":
return Optional.ofNullable(clazz.cast(layerDigest()));
case "layerAvailability":
return Optional.ofNullable(clazz.cast(layerAvailabilityAsString()));
case "layerSize":
return Optional.ofNullable(clazz.cast(layerSize()));
case "mediaType":
return Optional.ofNullable(clazz.cast(mediaType()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function