
software.amazon.awssdk.services.imagebuilder.model.ComponentVersion Maven / Gradle / Ivy
/*
* 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.imagebuilder.model;
import java.io.Serializable;
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.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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The defining characteristics of a specific version of an Amazon Web Services TOE component.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ComponentVersion implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("arn")
.getter(getter(ComponentVersion::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("arn").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
.getter(getter(ComponentVersion::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final SdkField VERSION_FIELD = SdkField. builder(MarshallingType.STRING).memberName("version")
.getter(getter(ComponentVersion::version)).setter(setter(Builder::version))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("version").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("description").getter(getter(ComponentVersion::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();
private static final SdkField PLATFORM_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("platform").getter(getter(ComponentVersion::platformAsString)).setter(setter(Builder::platform))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("platform").build()).build();
private static final SdkField> SUPPORTED_OS_VERSIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("supportedOsVersions")
.getter(getter(ComponentVersion::supportedOsVersions))
.setter(setter(Builder::supportedOsVersions))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("supportedOsVersions").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("type")
.getter(getter(ComponentVersion::typeAsString)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("type").build()).build();
private static final SdkField OWNER_FIELD = SdkField. builder(MarshallingType.STRING).memberName("owner")
.getter(getter(ComponentVersion::owner)).setter(setter(Builder::owner))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("owner").build()).build();
private static final SdkField DATE_CREATED_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("dateCreated").getter(getter(ComponentVersion::dateCreated)).setter(setter(Builder::dateCreated))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("dateCreated").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ARN_FIELD, NAME_FIELD,
VERSION_FIELD, DESCRIPTION_FIELD, PLATFORM_FIELD, SUPPORTED_OS_VERSIONS_FIELD, TYPE_FIELD, OWNER_FIELD,
DATE_CREATED_FIELD));
private static final long serialVersionUID = 1L;
private final String arn;
private final String name;
private final String version;
private final String description;
private final String platform;
private final List supportedOsVersions;
private final String type;
private final String owner;
private final String dateCreated;
private ComponentVersion(BuilderImpl builder) {
this.arn = builder.arn;
this.name = builder.name;
this.version = builder.version;
this.description = builder.description;
this.platform = builder.platform;
this.supportedOsVersions = builder.supportedOsVersions;
this.type = builder.type;
this.owner = builder.owner;
this.dateCreated = builder.dateCreated;
}
/**
*
* The Amazon Resource Name (ARN) of the component.
*
*
*
* Semantic versioning is included in each object's Amazon Resource Name (ARN), at the level that applies to that
* object as follows:
*
*
* -
*
* Versionless ARNs and Name ARNs do not include specific values in any of the nodes. The nodes are either left off
* entirely, or they are specified as wildcards, for example: x.x.x.
*
*
* -
*
* Version ARNs have only the first three nodes: <major>.<minor>.<patch>
*
*
* -
*
* Build version ARNs have all four nodes, and point to a specific build for a specific version of an object.
*
*
*
*
*
* @return The Amazon Resource Name (ARN) of the component.
*
* Semantic versioning is included in each object's Amazon Resource Name (ARN), at the level that applies to
* that object as follows:
*
*
* -
*
* Versionless ARNs and Name ARNs do not include specific values in any of the nodes. The nodes are either
* left off entirely, or they are specified as wildcards, for example: x.x.x.
*
*
* -
*
* Version ARNs have only the first three nodes: <major>.<minor>.<patch>
*
*
* -
*
* Build version ARNs have all four nodes, and point to a specific build for a specific version of an
* object.
*
*
*
*/
public final String arn() {
return arn;
}
/**
*
* The name of the component.
*
*
* @return The name of the component.
*/
public final String name() {
return name;
}
/**
*
* The semantic version of the component.
*
*
*
* The semantic version has four nodes: <major>.<minor>.<patch>/<build>. You can assign
* values for the first three, and can filter on all of them.
*
*
* Assignment: For the first three nodes you can assign any positive integer value, including zero, with an
* upper limit of 2^30-1, or 1073741823 for each node. Image Builder automatically assigns the build number to the
* fourth node.
*
*
* Patterns: You can use any numeric pattern that adheres to the assignment requirements for the nodes that
* you can assign. For example, you might choose a software version pattern, such as 1.0.0, or a date, such as
* 2021.01.01.
*
*
* Filtering: With semantic versioning, you have the flexibility to use wildcards (x) to specify the most
* recent versions or nodes when selecting the base image or components for your recipe. When you use a wildcard in
* any node, all nodes to the right of the first wildcard must also be wildcards.
*
*
*
* @return The semantic version of the component.
*
* The semantic version has four nodes: <major>.<minor>.<patch>/<build>. You can
* assign values for the first three, and can filter on all of them.
*
*
* Assignment: For the first three nodes you can assign any positive integer value, including zero,
* with an upper limit of 2^30-1, or 1073741823 for each node. Image Builder automatically assigns the build
* number to the fourth node.
*
*
* Patterns: You can use any numeric pattern that adheres to the assignment requirements for the
* nodes that you can assign. For example, you might choose a software version pattern, such as 1.0.0, or a
* date, such as 2021.01.01.
*
*
* Filtering: With semantic versioning, you have the flexibility to use wildcards (x) to specify the
* most recent versions or nodes when selecting the base image or components for your recipe. When you use a
* wildcard in any node, all nodes to the right of the first wildcard must also be wildcards.
*
*/
public final String version() {
return version;
}
/**
*
* The description of the component.
*
*
* @return The description of the component.
*/
public final String description() {
return description;
}
/**
*
* The platform of the component.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #platform} will
* return {@link Platform#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #platformAsString}.
*
*
* @return The platform of the component.
* @see Platform
*/
public final Platform platform() {
return Platform.fromValue(platform);
}
/**
*
* The platform of the component.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #platform} will
* return {@link Platform#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #platformAsString}.
*
*
* @return The platform of the component.
* @see Platform
*/
public final String platformAsString() {
return platform;
}
/**
* For responses, this returns true if the service returned a value for the SupportedOsVersions property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasSupportedOsVersions() {
return supportedOsVersions != null && !(supportedOsVersions instanceof SdkAutoConstructList);
}
/**
*
* he operating system (OS) version supported by the component. If the OS information is available, a prefix match
* is performed against the base image OS version during image recipe creation.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasSupportedOsVersions} method.
*
*
* @return he operating system (OS) version supported by the component. If the OS information is available, a prefix
* match is performed against the base image OS version during image recipe creation.
*/
public final List supportedOsVersions() {
return supportedOsVersions;
}
/**
*
* The type of the component denotes whether the component is used to build the image or only to test it.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link ComponentType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of the component denotes whether the component is used to build the image or only to test it.
* @see ComponentType
*/
public final ComponentType type() {
return ComponentType.fromValue(type);
}
/**
*
* The type of the component denotes whether the component is used to build the image or only to test it.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link ComponentType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of the component denotes whether the component is used to build the image or only to test it.
* @see ComponentType
*/
public final String typeAsString() {
return type;
}
/**
*
* The owner of the component.
*
*
* @return The owner of the component.
*/
public final String owner() {
return owner;
}
/**
*
* The date that the component was created.
*
*
* @return The date that the component was created.
*/
public final String dateCreated() {
return dateCreated;
}
@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(arn());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(version());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(platformAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasSupportedOsVersions() ? supportedOsVersions() : null);
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(owner());
hashCode = 31 * hashCode + Objects.hashCode(dateCreated());
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 ComponentVersion)) {
return false;
}
ComponentVersion other = (ComponentVersion) obj;
return Objects.equals(arn(), other.arn()) && Objects.equals(name(), other.name())
&& Objects.equals(version(), other.version()) && Objects.equals(description(), other.description())
&& Objects.equals(platformAsString(), other.platformAsString())
&& hasSupportedOsVersions() == other.hasSupportedOsVersions()
&& Objects.equals(supportedOsVersions(), other.supportedOsVersions())
&& Objects.equals(typeAsString(), other.typeAsString()) && Objects.equals(owner(), other.owner())
&& Objects.equals(dateCreated(), other.dateCreated());
}
/**
* 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("ComponentVersion").add("Arn", arn()).add("Name", name()).add("Version", version())
.add("Description", description()).add("Platform", platformAsString())
.add("SupportedOsVersions", hasSupportedOsVersions() ? supportedOsVersions() : null).add("Type", typeAsString())
.add("Owner", owner()).add("DateCreated", dateCreated()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "arn":
return Optional.ofNullable(clazz.cast(arn()));
case "name":
return Optional.ofNullable(clazz.cast(name()));
case "version":
return Optional.ofNullable(clazz.cast(version()));
case "description":
return Optional.ofNullable(clazz.cast(description()));
case "platform":
return Optional.ofNullable(clazz.cast(platformAsString()));
case "supportedOsVersions":
return Optional.ofNullable(clazz.cast(supportedOsVersions()));
case "type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "owner":
return Optional.ofNullable(clazz.cast(owner()));
case "dateCreated":
return Optional.ofNullable(clazz.cast(dateCreated()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function