software.amazon.awssdk.services.codegurureviewer.model.CodeReview Maven / Gradle / Ivy
Show all versions of codegurureviewer 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.codegurureviewer.model;
import java.io.Serializable;
import java.time.Instant;
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.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.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;
/**
*
* Information about a code review. A code review belongs to the associated repository that contains the reviewed code.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CodeReview implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(CodeReview::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField CODE_REVIEW_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CodeReviewArn").getter(getter(CodeReview::codeReviewArn)).setter(setter(Builder::codeReviewArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CodeReviewArn").build()).build();
private static final SdkField REPOSITORY_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RepositoryName").getter(getter(CodeReview::repositoryName)).setter(setter(Builder::repositoryName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RepositoryName").build()).build();
private static final SdkField OWNER_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Owner")
.getter(getter(CodeReview::owner)).setter(setter(Builder::owner))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Owner").build()).build();
private static final SdkField PROVIDER_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ProviderType").getter(getter(CodeReview::providerTypeAsString)).setter(setter(Builder::providerType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ProviderType").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(CodeReview::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField STATE_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StateReason").getter(getter(CodeReview::stateReason)).setter(setter(Builder::stateReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StateReason").build()).build();
private static final SdkField CREATED_TIME_STAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreatedTimeStamp").getter(getter(CodeReview::createdTimeStamp))
.setter(setter(Builder::createdTimeStamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedTimeStamp").build()).build();
private static final SdkField LAST_UPDATED_TIME_STAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastUpdatedTimeStamp").getter(getter(CodeReview::lastUpdatedTimeStamp))
.setter(setter(Builder::lastUpdatedTimeStamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastUpdatedTimeStamp").build())
.build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Type")
.getter(getter(CodeReview::typeAsString)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type").build()).build();
private static final SdkField PULL_REQUEST_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PullRequestId").getter(getter(CodeReview::pullRequestId)).setter(setter(Builder::pullRequestId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PullRequestId").build()).build();
private static final SdkField SOURCE_CODE_TYPE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("SourceCodeType")
.getter(getter(CodeReview::sourceCodeType)).setter(setter(Builder::sourceCodeType))
.constructor(SourceCodeType::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceCodeType").build()).build();
private static final SdkField ASSOCIATION_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AssociationArn").getter(getter(CodeReview::associationArn)).setter(setter(Builder::associationArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssociationArn").build()).build();
private static final SdkField METRICS_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Metrics").getter(getter(CodeReview::metrics)).setter(setter(Builder::metrics))
.constructor(Metrics::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Metrics").build()).build();
private static final SdkField> ANALYSIS_TYPES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("AnalysisTypes")
.getter(getter(CodeReview::analysisTypesAsStrings))
.setter(setter(Builder::analysisTypesWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AnalysisTypes").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 CONFIG_FILE_STATE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ConfigFileState").getter(getter(CodeReview::configFileStateAsString))
.setter(setter(Builder::configFileState))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ConfigFileState").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD,
CODE_REVIEW_ARN_FIELD, REPOSITORY_NAME_FIELD, OWNER_FIELD, PROVIDER_TYPE_FIELD, STATE_FIELD, STATE_REASON_FIELD,
CREATED_TIME_STAMP_FIELD, LAST_UPDATED_TIME_STAMP_FIELD, TYPE_FIELD, PULL_REQUEST_ID_FIELD, SOURCE_CODE_TYPE_FIELD,
ASSOCIATION_ARN_FIELD, METRICS_FIELD, ANALYSIS_TYPES_FIELD, CONFIG_FILE_STATE_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final String codeReviewArn;
private final String repositoryName;
private final String owner;
private final String providerType;
private final String state;
private final String stateReason;
private final Instant createdTimeStamp;
private final Instant lastUpdatedTimeStamp;
private final String type;
private final String pullRequestId;
private final SourceCodeType sourceCodeType;
private final String associationArn;
private final Metrics metrics;
private final List analysisTypes;
private final String configFileState;
private CodeReview(BuilderImpl builder) {
this.name = builder.name;
this.codeReviewArn = builder.codeReviewArn;
this.repositoryName = builder.repositoryName;
this.owner = builder.owner;
this.providerType = builder.providerType;
this.state = builder.state;
this.stateReason = builder.stateReason;
this.createdTimeStamp = builder.createdTimeStamp;
this.lastUpdatedTimeStamp = builder.lastUpdatedTimeStamp;
this.type = builder.type;
this.pullRequestId = builder.pullRequestId;
this.sourceCodeType = builder.sourceCodeType;
this.associationArn = builder.associationArn;
this.metrics = builder.metrics;
this.analysisTypes = builder.analysisTypes;
this.configFileState = builder.configFileState;
}
/**
*
* The name of the code review.
*
*
* @return The name of the code review.
*/
public final String name() {
return name;
}
/**
*
* The Amazon Resource Name (ARN) of the CodeReview object.
*
*
* @return The Amazon Resource Name (ARN) of the CodeReview
* object.
*/
public final String codeReviewArn() {
return codeReviewArn;
}
/**
*
* The name of the repository.
*
*
* @return The name of the repository.
*/
public final String repositoryName() {
return repositoryName;
}
/**
*
* The owner of the repository. For an Amazon Web Services CodeCommit repository, this is the Amazon Web Services
* account ID of the account that owns the repository. For a GitHub, GitHub Enterprise Server, or Bitbucket
* repository, this is the username for the account that owns the repository. For an S3 repository, it can be the
* username or Amazon Web Services account ID.
*
*
* @return The owner of the repository. For an Amazon Web Services CodeCommit repository, this is the Amazon Web
* Services account ID of the account that owns the repository. For a GitHub, GitHub Enterprise Server, or
* Bitbucket repository, this is the username for the account that owns the repository. For an S3
* repository, it can be the username or Amazon Web Services account ID.
*/
public final String owner() {
return owner;
}
/**
*
* The type of repository that contains the reviewed code (for example, GitHub or Bitbucket).
*
*
* 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 type of repository that contains the reviewed code (for example, GitHub or Bitbucket).
* @see ProviderType
*/
public final ProviderType providerType() {
return ProviderType.fromValue(providerType);
}
/**
*
* The type of repository that contains the reviewed code (for example, GitHub or Bitbucket).
*
*
* 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 type of repository that contains the reviewed code (for example, GitHub or Bitbucket).
* @see ProviderType
*/
public final String providerTypeAsString() {
return providerType;
}
/**
*
* The valid code review states are:
*
*
* -
*
* Completed
: The code review is complete.
*
*
* -
*
* Pending
: The code review started and has not completed or failed.
*
*
* -
*
* Failed
: The code review failed.
*
*
* -
*
* Deleting
: The code review is being deleted.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link JobState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The valid code review states are:
*
* -
*
* Completed
: The code review is complete.
*
*
* -
*
* Pending
: The code review started and has not completed or failed.
*
*
* -
*
* Failed
: The code review failed.
*
*
* -
*
* Deleting
: The code review is being deleted.
*
*
* @see JobState
*/
public final JobState state() {
return JobState.fromValue(state);
}
/**
*
* The valid code review states are:
*
*
* -
*
* Completed
: The code review is complete.
*
*
* -
*
* Pending
: The code review started and has not completed or failed.
*
*
* -
*
* Failed
: The code review failed.
*
*
* -
*
* Deleting
: The code review is being deleted.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link JobState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The valid code review states are:
*
* -
*
* Completed
: The code review is complete.
*
*
* -
*
* Pending
: The code review started and has not completed or failed.
*
*
* -
*
* Failed
: The code review failed.
*
*
* -
*
* Deleting
: The code review is being deleted.
*
*
* @see JobState
*/
public final String stateAsString() {
return state;
}
/**
*
* The reason for the state of the code review.
*
*
* @return The reason for the state of the code review.
*/
public final String stateReason() {
return stateReason;
}
/**
*
* The time, in milliseconds since the epoch, when the code review was created.
*
*
* @return The time, in milliseconds since the epoch, when the code review was created.
*/
public final Instant createdTimeStamp() {
return createdTimeStamp;
}
/**
*
* The time, in milliseconds since the epoch, when the code review was last updated.
*
*
* @return The time, in milliseconds since the epoch, when the code review was last updated.
*/
public final Instant lastUpdatedTimeStamp() {
return lastUpdatedTimeStamp;
}
/**
*
* The type of code review.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link Type#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of code review.
* @see Type
*/
public final Type type() {
return Type.fromValue(type);
}
/**
*
* The type of code review.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link Type#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of code review.
* @see Type
*/
public final String typeAsString() {
return type;
}
/**
*
* The pull request ID for the code review.
*
*
* @return The pull request ID for the code review.
*/
public final String pullRequestId() {
return pullRequestId;
}
/**
*
* The type of the source code for the code review.
*
*
* @return The type of the source code for the code review.
*/
public final SourceCodeType sourceCodeType() {
return sourceCodeType;
}
/**
*
* The Amazon Resource Name (ARN) of the RepositoryAssociation that contains the reviewed source code. You can retrieve associated repository ARNs by
* calling
* ListRepositoryAssociations.
*
*
* @return The Amazon Resource Name (ARN) of the RepositoryAssociation that contains the reviewed source code. You can retrieve associated repository
* ARNs by calling ListRepositoryAssociations.
*/
public final String associationArn() {
return associationArn;
}
/**
*
* The statistics from the code review.
*
*
* @return The statistics from the code review.
*/
public final Metrics metrics() {
return metrics;
}
/**
*
* The types of analysis performed during a repository analysis or a pull request review. You can specify either
* Security
, CodeQuality
, or both.
*
*
* 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 #hasAnalysisTypes} method.
*
*
* @return The types of analysis performed during a repository analysis or a pull request review. You can specify
* either Security
, CodeQuality
, or both.
*/
public final List analysisTypes() {
return AnalysisTypesCopier.copyStringToEnum(analysisTypes);
}
/**
* For responses, this returns true if the service returned a value for the AnalysisTypes 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 hasAnalysisTypes() {
return analysisTypes != null && !(analysisTypes instanceof SdkAutoConstructList);
}
/**
*
* The types of analysis performed during a repository analysis or a pull request review. You can specify either
* Security
, CodeQuality
, or both.
*
*
* 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 #hasAnalysisTypes} method.
*
*
* @return The types of analysis performed during a repository analysis or a pull request review. You can specify
* either Security
, CodeQuality
, or both.
*/
public final List analysisTypesAsStrings() {
return analysisTypes;
}
/**
*
* The state of the aws-codeguru-reviewer.yml
configuration file that allows the configuration of the
* CodeGuru Reviewer analysis. The file either exists, doesn't exist, or exists with errors at the root directory of
* your repository.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #configFileState}
* will return {@link ConfigFileState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #configFileStateAsString}.
*
*
* @return The state of the aws-codeguru-reviewer.yml
configuration file that allows the configuration
* of the CodeGuru Reviewer analysis. The file either exists, doesn't exist, or exists with errors at the
* root directory of your repository.
* @see ConfigFileState
*/
public final ConfigFileState configFileState() {
return ConfigFileState.fromValue(configFileState);
}
/**
*
* The state of the aws-codeguru-reviewer.yml
configuration file that allows the configuration of the
* CodeGuru Reviewer analysis. The file either exists, doesn't exist, or exists with errors at the root directory of
* your repository.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #configFileState}
* will return {@link ConfigFileState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #configFileStateAsString}.
*
*
* @return The state of the aws-codeguru-reviewer.yml
configuration file that allows the configuration
* of the CodeGuru Reviewer analysis. The file either exists, doesn't exist, or exists with errors at the
* root directory of your repository.
* @see ConfigFileState
*/
public final String configFileStateAsString() {
return configFileState;
}
@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(name());
hashCode = 31 * hashCode + Objects.hashCode(codeReviewArn());
hashCode = 31 * hashCode + Objects.hashCode(repositoryName());
hashCode = 31 * hashCode + Objects.hashCode(owner());
hashCode = 31 * hashCode + Objects.hashCode(providerTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateReason());
hashCode = 31 * hashCode + Objects.hashCode(createdTimeStamp());
hashCode = 31 * hashCode + Objects.hashCode(lastUpdatedTimeStamp());
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(pullRequestId());
hashCode = 31 * hashCode + Objects.hashCode(sourceCodeType());
hashCode = 31 * hashCode + Objects.hashCode(associationArn());
hashCode = 31 * hashCode + Objects.hashCode(metrics());
hashCode = 31 * hashCode + Objects.hashCode(hasAnalysisTypes() ? analysisTypesAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(configFileStateAsString());
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 CodeReview)) {
return false;
}
CodeReview other = (CodeReview) obj;
return Objects.equals(name(), other.name()) && Objects.equals(codeReviewArn(), other.codeReviewArn())
&& Objects.equals(repositoryName(), other.repositoryName()) && Objects.equals(owner(), other.owner())
&& Objects.equals(providerTypeAsString(), other.providerTypeAsString())
&& Objects.equals(stateAsString(), other.stateAsString()) && Objects.equals(stateReason(), other.stateReason())
&& Objects.equals(createdTimeStamp(), other.createdTimeStamp())
&& Objects.equals(lastUpdatedTimeStamp(), other.lastUpdatedTimeStamp())
&& Objects.equals(typeAsString(), other.typeAsString()) && Objects.equals(pullRequestId(), other.pullRequestId())
&& Objects.equals(sourceCodeType(), other.sourceCodeType())
&& Objects.equals(associationArn(), other.associationArn()) && Objects.equals(metrics(), other.metrics())
&& hasAnalysisTypes() == other.hasAnalysisTypes()
&& Objects.equals(analysisTypesAsStrings(), other.analysisTypesAsStrings())
&& Objects.equals(configFileStateAsString(), other.configFileStateAsString());
}
/**
* 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("CodeReview").add("Name", name()).add("CodeReviewArn", codeReviewArn())
.add("RepositoryName", repositoryName()).add("Owner", owner()).add("ProviderType", providerTypeAsString())
.add("State", stateAsString()).add("StateReason", stateReason()).add("CreatedTimeStamp", createdTimeStamp())
.add("LastUpdatedTimeStamp", lastUpdatedTimeStamp()).add("Type", typeAsString())
.add("PullRequestId", pullRequestId()).add("SourceCodeType", sourceCodeType())
.add("AssociationArn", associationArn()).add("Metrics", metrics())
.add("AnalysisTypes", hasAnalysisTypes() ? analysisTypesAsStrings() : null)
.add("ConfigFileState", configFileStateAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "CodeReviewArn":
return Optional.ofNullable(clazz.cast(codeReviewArn()));
case "RepositoryName":
return Optional.ofNullable(clazz.cast(repositoryName()));
case "Owner":
return Optional.ofNullable(clazz.cast(owner()));
case "ProviderType":
return Optional.ofNullable(clazz.cast(providerTypeAsString()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "StateReason":
return Optional.ofNullable(clazz.cast(stateReason()));
case "CreatedTimeStamp":
return Optional.ofNullable(clazz.cast(createdTimeStamp()));
case "LastUpdatedTimeStamp":
return Optional.ofNullable(clazz.cast(lastUpdatedTimeStamp()));
case "Type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "PullRequestId":
return Optional.ofNullable(clazz.cast(pullRequestId()));
case "SourceCodeType":
return Optional.ofNullable(clazz.cast(sourceCodeType()));
case "AssociationArn":
return Optional.ofNullable(clazz.cast(associationArn()));
case "Metrics":
return Optional.ofNullable(clazz.cast(metrics()));
case "AnalysisTypes":
return Optional.ofNullable(clazz.cast(analysisTypesAsStrings()));
case "ConfigFileState":
return Optional.ofNullable(clazz.cast(configFileStateAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function