software.amazon.awssdk.services.codegurureviewer.model.RecommendationSummary 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.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;
/**
*
* Information about recommendations.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class RecommendationSummary implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField FILE_PATH_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("FilePath").getter(getter(RecommendationSummary::filePath)).setter(setter(Builder::filePath))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FilePath").build()).build();
private static final SdkField RECOMMENDATION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RecommendationId").getter(getter(RecommendationSummary::recommendationId))
.setter(setter(Builder::recommendationId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecommendationId").build()).build();
private static final SdkField START_LINE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("StartLine").getter(getter(RecommendationSummary::startLine)).setter(setter(Builder::startLine))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartLine").build()).build();
private static final SdkField END_LINE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("EndLine").getter(getter(RecommendationSummary::endLine)).setter(setter(Builder::endLine))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndLine").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(RecommendationSummary::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField RECOMMENDATION_CATEGORY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RecommendationCategory").getter(getter(RecommendationSummary::recommendationCategoryAsString))
.setter(setter(Builder::recommendationCategory))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecommendationCategory").build())
.build();
private static final SdkField RULE_METADATA_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("RuleMetadata").getter(getter(RecommendationSummary::ruleMetadata)).setter(setter(Builder::ruleMetadata))
.constructor(RuleMetadata::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuleMetadata").build()).build();
private static final SdkField SEVERITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Severity").getter(getter(RecommendationSummary::severityAsString)).setter(setter(Builder::severity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Severity").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FILE_PATH_FIELD,
RECOMMENDATION_ID_FIELD, START_LINE_FIELD, END_LINE_FIELD, DESCRIPTION_FIELD, RECOMMENDATION_CATEGORY_FIELD,
RULE_METADATA_FIELD, SEVERITY_FIELD));
private static final long serialVersionUID = 1L;
private final String filePath;
private final String recommendationId;
private final Integer startLine;
private final Integer endLine;
private final String description;
private final String recommendationCategory;
private final RuleMetadata ruleMetadata;
private final String severity;
private RecommendationSummary(BuilderImpl builder) {
this.filePath = builder.filePath;
this.recommendationId = builder.recommendationId;
this.startLine = builder.startLine;
this.endLine = builder.endLine;
this.description = builder.description;
this.recommendationCategory = builder.recommendationCategory;
this.ruleMetadata = builder.ruleMetadata;
this.severity = builder.severity;
}
/**
*
* Name of the file on which a recommendation is provided.
*
*
* @return Name of the file on which a recommendation is provided.
*/
public final String filePath() {
return filePath;
}
/**
*
* The recommendation ID that can be used to track the provided recommendations. Later on it can be used to collect
* the feedback.
*
*
* @return The recommendation ID that can be used to track the provided recommendations. Later on it can be used to
* collect the feedback.
*/
public final String recommendationId() {
return recommendationId;
}
/**
*
* Start line from where the recommendation is applicable in the source commit or source branch.
*
*
* @return Start line from where the recommendation is applicable in the source commit or source branch.
*/
public final Integer startLine() {
return startLine;
}
/**
*
* Last line where the recommendation is applicable in the source commit or source branch. For a single line comment
* the start line and end line values are the same.
*
*
* @return Last line where the recommendation is applicable in the source commit or source branch. For a single line
* comment the start line and end line values are the same.
*/
public final Integer endLine() {
return endLine;
}
/**
*
* A description of the recommendation generated by CodeGuru Reviewer for the lines of code between the start line
* and the end line.
*
*
* @return A description of the recommendation generated by CodeGuru Reviewer for the lines of code between the
* start line and the end line.
*/
public final String description() {
return description;
}
/**
*
* The type of a recommendation.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #recommendationCategory} will return {@link RecommendationCategory#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #recommendationCategoryAsString}.
*
*
* @return The type of a recommendation.
* @see RecommendationCategory
*/
public final RecommendationCategory recommendationCategory() {
return RecommendationCategory.fromValue(recommendationCategory);
}
/**
*
* The type of a recommendation.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #recommendationCategory} will return {@link RecommendationCategory#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #recommendationCategoryAsString}.
*
*
* @return The type of a recommendation.
* @see RecommendationCategory
*/
public final String recommendationCategoryAsString() {
return recommendationCategory;
}
/**
*
* Metadata about a rule. Rule metadata includes an ID, a name, a list of tags, and a short and long description.
* CodeGuru Reviewer uses rules to analyze code. A rule's recommendation is included in analysis results if code is
* detected that violates the rule.
*
*
* @return Metadata about a rule. Rule metadata includes an ID, a name, a list of tags, and a short and long
* description. CodeGuru Reviewer uses rules to analyze code. A rule's recommendation is included in
* analysis results if code is detected that violates the rule.
*/
public final RuleMetadata ruleMetadata() {
return ruleMetadata;
}
/**
*
* The severity of the issue in the code that generated this recommendation.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #severity} will
* return {@link Severity#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #severityAsString}.
*
*
* @return The severity of the issue in the code that generated this recommendation.
* @see Severity
*/
public final Severity severity() {
return Severity.fromValue(severity);
}
/**
*
* The severity of the issue in the code that generated this recommendation.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #severity} will
* return {@link Severity#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #severityAsString}.
*
*
* @return The severity of the issue in the code that generated this recommendation.
* @see Severity
*/
public final String severityAsString() {
return severity;
}
@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(filePath());
hashCode = 31 * hashCode + Objects.hashCode(recommendationId());
hashCode = 31 * hashCode + Objects.hashCode(startLine());
hashCode = 31 * hashCode + Objects.hashCode(endLine());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(recommendationCategoryAsString());
hashCode = 31 * hashCode + Objects.hashCode(ruleMetadata());
hashCode = 31 * hashCode + Objects.hashCode(severityAsString());
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 RecommendationSummary)) {
return false;
}
RecommendationSummary other = (RecommendationSummary) obj;
return Objects.equals(filePath(), other.filePath()) && Objects.equals(recommendationId(), other.recommendationId())
&& Objects.equals(startLine(), other.startLine()) && Objects.equals(endLine(), other.endLine())
&& Objects.equals(description(), other.description())
&& Objects.equals(recommendationCategoryAsString(), other.recommendationCategoryAsString())
&& Objects.equals(ruleMetadata(), other.ruleMetadata())
&& Objects.equals(severityAsString(), other.severityAsString());
}
/**
* 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("RecommendationSummary").add("FilePath", filePath()).add("RecommendationId", recommendationId())
.add("StartLine", startLine()).add("EndLine", endLine()).add("Description", description())
.add("RecommendationCategory", recommendationCategoryAsString()).add("RuleMetadata", ruleMetadata())
.add("Severity", severityAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "FilePath":
return Optional.ofNullable(clazz.cast(filePath()));
case "RecommendationId":
return Optional.ofNullable(clazz.cast(recommendationId()));
case "StartLine":
return Optional.ofNullable(clazz.cast(startLine()));
case "EndLine":
return Optional.ofNullable(clazz.cast(endLine()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "RecommendationCategory":
return Optional.ofNullable(clazz.cast(recommendationCategoryAsString()));
case "RuleMetadata":
return Optional.ofNullable(clazz.cast(ruleMetadata()));
case "Severity":
return Optional.ofNullable(clazz.cast(severityAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function