
software.amazon.awssdk.services.codestarconnections.model.Revision 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.codestarconnections.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;
/**
*
* Information about the revision for a specific sync event, such as the branch, owner ID, and name of the repository.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Revision implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField BRANCH_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Branch")
.getter(getter(Revision::branch)).setter(setter(Builder::branch))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Branch").build()).build();
private static final SdkField DIRECTORY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Directory").getter(getter(Revision::directory)).setter(setter(Builder::directory))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Directory").build()).build();
private static final SdkField OWNER_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("OwnerId").getter(getter(Revision::ownerId)).setter(setter(Builder::ownerId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OwnerId").build()).build();
private static final SdkField REPOSITORY_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RepositoryName").getter(getter(Revision::repositoryName)).setter(setter(Builder::repositoryName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RepositoryName").build()).build();
private static final SdkField PROVIDER_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ProviderType").getter(getter(Revision::providerTypeAsString)).setter(setter(Builder::providerType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ProviderType").build()).build();
private static final SdkField SHA_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Sha")
.getter(getter(Revision::sha)).setter(setter(Builder::sha))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Sha").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BRANCH_FIELD, DIRECTORY_FIELD,
OWNER_ID_FIELD, REPOSITORY_NAME_FIELD, PROVIDER_TYPE_FIELD, SHA_FIELD));
private static final long serialVersionUID = 1L;
private final String branch;
private final String directory;
private final String ownerId;
private final String repositoryName;
private final String providerType;
private final String sha;
private Revision(BuilderImpl builder) {
this.branch = builder.branch;
this.directory = builder.directory;
this.ownerId = builder.ownerId;
this.repositoryName = builder.repositoryName;
this.providerType = builder.providerType;
this.sha = builder.sha;
}
/**
*
* The branch name for a specific revision.
*
*
* @return The branch name for a specific revision.
*/
public final String branch() {
return branch;
}
/**
*
* The directory, if any, for a specific revision.
*
*
* @return The directory, if any, for a specific revision.
*/
public final String directory() {
return directory;
}
/**
*
* The owner ID for a specific revision, such as the GitHub owner ID for a GitHub repository.
*
*
* @return The owner ID for a specific revision, such as the GitHub owner ID for a GitHub repository.
*/
public final String ownerId() {
return ownerId;
}
/**
*
* The repository name for a specific revision.
*
*
* @return The repository name for a specific revision.
*/
public final String repositoryName() {
return repositoryName;
}
/**
*
* The provider type for a revision, such as GitHub.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #providerType} will
* return {@link ProviderType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #providerTypeAsString}.
*
*
* @return The provider type for a revision, such as GitHub.
* @see ProviderType
*/
public final ProviderType providerType() {
return ProviderType.fromValue(providerType);
}
/**
*
* The provider type for a revision, such as GitHub.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #providerType} will
* return {@link ProviderType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #providerTypeAsString}.
*
*
* @return The provider type for a revision, such as GitHub.
* @see ProviderType
*/
public final String providerTypeAsString() {
return providerType;
}
/**
*
* The SHA, such as the commit ID, for a specific revision.
*
*
* @return The SHA, such as the commit ID, for a specific revision.
*/
public final String sha() {
return sha;
}
@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(branch());
hashCode = 31 * hashCode + Objects.hashCode(directory());
hashCode = 31 * hashCode + Objects.hashCode(ownerId());
hashCode = 31 * hashCode + Objects.hashCode(repositoryName());
hashCode = 31 * hashCode + Objects.hashCode(providerTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(sha());
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 Revision)) {
return false;
}
Revision other = (Revision) obj;
return Objects.equals(branch(), other.branch()) && Objects.equals(directory(), other.directory())
&& Objects.equals(ownerId(), other.ownerId()) && Objects.equals(repositoryName(), other.repositoryName())
&& Objects.equals(providerTypeAsString(), other.providerTypeAsString()) && Objects.equals(sha(), other.sha());
}
/**
* 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("Revision").add("Branch", branch()).add("Directory", directory()).add("OwnerId", ownerId())
.add("RepositoryName", repositoryName()).add("ProviderType", providerTypeAsString()).add("Sha", sha()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Branch":
return Optional.ofNullable(clazz.cast(branch()));
case "Directory":
return Optional.ofNullable(clazz.cast(directory()));
case "OwnerId":
return Optional.ofNullable(clazz.cast(ownerId()));
case "RepositoryName":
return Optional.ofNullable(clazz.cast(repositoryName()));
case "ProviderType":
return Optional.ofNullable(clazz.cast(providerTypeAsString()));
case "Sha":
return Optional.ofNullable(clazz.cast(sha()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function