software.amazon.awssdk.services.codecommit.model.PullRequestTarget Maven / Gradle / Ivy
Show all versions of codecommit 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.codecommit.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;
/**
*
* Returns information about a pull request target.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PullRequestTarget implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField REPOSITORY_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("repositoryName").getter(getter(PullRequestTarget::repositoryName))
.setter(setter(Builder::repositoryName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("repositoryName").build()).build();
private static final SdkField SOURCE_REFERENCE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("sourceReference").getter(getter(PullRequestTarget::sourceReference))
.setter(setter(Builder::sourceReference))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("sourceReference").build()).build();
private static final SdkField DESTINATION_REFERENCE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("destinationReference").getter(getter(PullRequestTarget::destinationReference))
.setter(setter(Builder::destinationReference))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("destinationReference").build())
.build();
private static final SdkField DESTINATION_COMMIT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("destinationCommit").getter(getter(PullRequestTarget::destinationCommit))
.setter(setter(Builder::destinationCommit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("destinationCommit").build()).build();
private static final SdkField SOURCE_COMMIT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("sourceCommit").getter(getter(PullRequestTarget::sourceCommit)).setter(setter(Builder::sourceCommit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("sourceCommit").build()).build();
private static final SdkField MERGE_BASE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("mergeBase").getter(getter(PullRequestTarget::mergeBase)).setter(setter(Builder::mergeBase))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("mergeBase").build()).build();
private static final SdkField MERGE_METADATA_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("mergeMetadata")
.getter(getter(PullRequestTarget::mergeMetadata)).setter(setter(Builder::mergeMetadata))
.constructor(MergeMetadata::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("mergeMetadata").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(REPOSITORY_NAME_FIELD,
SOURCE_REFERENCE_FIELD, DESTINATION_REFERENCE_FIELD, DESTINATION_COMMIT_FIELD, SOURCE_COMMIT_FIELD, MERGE_BASE_FIELD,
MERGE_METADATA_FIELD));
private static final long serialVersionUID = 1L;
private final String repositoryName;
private final String sourceReference;
private final String destinationReference;
private final String destinationCommit;
private final String sourceCommit;
private final String mergeBase;
private final MergeMetadata mergeMetadata;
private PullRequestTarget(BuilderImpl builder) {
this.repositoryName = builder.repositoryName;
this.sourceReference = builder.sourceReference;
this.destinationReference = builder.destinationReference;
this.destinationCommit = builder.destinationCommit;
this.sourceCommit = builder.sourceCommit;
this.mergeBase = builder.mergeBase;
this.mergeMetadata = builder.mergeMetadata;
}
/**
*
* The name of the repository that contains the pull request source and destination branches.
*
*
* @return The name of the repository that contains the pull request source and destination branches.
*/
public final String repositoryName() {
return repositoryName;
}
/**
*
* The branch of the repository that contains the changes for the pull request. Also known as the source branch.
*
*
* @return The branch of the repository that contains the changes for the pull request. Also known as the source
* branch.
*/
public final String sourceReference() {
return sourceReference;
}
/**
*
* The branch of the repository where the pull request changes are merged. Also known as the destination branch.
*
*
* @return The branch of the repository where the pull request changes are merged. Also known as the destination
* branch.
*/
public final String destinationReference() {
return destinationReference;
}
/**
*
* The full commit ID that is the tip of the destination branch. This is the commit where the pull request was or
* will be merged.
*
*
* @return The full commit ID that is the tip of the destination branch. This is the commit where the pull request
* was or will be merged.
*/
public final String destinationCommit() {
return destinationCommit;
}
/**
*
* The full commit ID of the tip of the source branch used to create the pull request. If the pull request branch is
* updated by a push while the pull request is open, the commit ID changes to reflect the new tip of the branch.
*
*
* @return The full commit ID of the tip of the source branch used to create the pull request. If the pull request
* branch is updated by a push while the pull request is open, the commit ID changes to reflect the new tip
* of the branch.
*/
public final String sourceCommit() {
return sourceCommit;
}
/**
*
* The commit ID of the most recent commit that the source branch and the destination branch have in common.
*
*
* @return The commit ID of the most recent commit that the source branch and the destination branch have in common.
*/
public final String mergeBase() {
return mergeBase;
}
/**
*
* Returns metadata about the state of the merge, including whether the merge has been made.
*
*
* @return Returns metadata about the state of the merge, including whether the merge has been made.
*/
public final MergeMetadata mergeMetadata() {
return mergeMetadata;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(repositoryName());
hashCode = 31 * hashCode + Objects.hashCode(sourceReference());
hashCode = 31 * hashCode + Objects.hashCode(destinationReference());
hashCode = 31 * hashCode + Objects.hashCode(destinationCommit());
hashCode = 31 * hashCode + Objects.hashCode(sourceCommit());
hashCode = 31 * hashCode + Objects.hashCode(mergeBase());
hashCode = 31 * hashCode + Objects.hashCode(mergeMetadata());
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 PullRequestTarget)) {
return false;
}
PullRequestTarget other = (PullRequestTarget) obj;
return Objects.equals(repositoryName(), other.repositoryName())
&& Objects.equals(sourceReference(), other.sourceReference())
&& Objects.equals(destinationReference(), other.destinationReference())
&& Objects.equals(destinationCommit(), other.destinationCommit())
&& Objects.equals(sourceCommit(), other.sourceCommit()) && Objects.equals(mergeBase(), other.mergeBase())
&& Objects.equals(mergeMetadata(), other.mergeMetadata());
}
/**
* 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("PullRequestTarget").add("RepositoryName", repositoryName())
.add("SourceReference", sourceReference()).add("DestinationReference", destinationReference())
.add("DestinationCommit", destinationCommit()).add("SourceCommit", sourceCommit()).add("MergeBase", mergeBase())
.add("MergeMetadata", mergeMetadata()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "repositoryName":
return Optional.ofNullable(clazz.cast(repositoryName()));
case "sourceReference":
return Optional.ofNullable(clazz.cast(sourceReference()));
case "destinationReference":
return Optional.ofNullable(clazz.cast(destinationReference()));
case "destinationCommit":
return Optional.ofNullable(clazz.cast(destinationCommit()));
case "sourceCommit":
return Optional.ofNullable(clazz.cast(sourceCommit()));
case "mergeBase":
return Optional.ofNullable(clazz.cast(mergeBase()));
case "mergeMetadata":
return Optional.ofNullable(clazz.cast(mergeMetadata()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function