software.amazon.awssdk.services.codebuild.model.CodeCoverage Maven / Gradle / Ivy
Show all versions of codebuild 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.codebuild.model;
import java.io.Serializable;
import java.time.Instant;
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;
/**
*
* Contains code coverage report information.
*
*
* Line coverage measures how many statements your tests cover. A statement is a single instruction, not including
* comments, conditionals, etc.
*
*
* Branch coverage determines if your tests cover every possible branch of a control structure, such as an
* if
or case
statement.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CodeCoverage implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("id")
.getter(getter(CodeCoverage::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("id").build()).build();
private static final SdkField REPORT_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("reportARN").getter(getter(CodeCoverage::reportARN)).setter(setter(Builder::reportARN))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("reportARN").build()).build();
private static final SdkField FILE_PATH_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("filePath").getter(getter(CodeCoverage::filePath)).setter(setter(Builder::filePath))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("filePath").build()).build();
private static final SdkField LINE_COVERAGE_PERCENTAGE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("lineCoveragePercentage").getter(getter(CodeCoverage::lineCoveragePercentage))
.setter(setter(Builder::lineCoveragePercentage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lineCoveragePercentage").build())
.build();
private static final SdkField LINES_COVERED_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("linesCovered").getter(getter(CodeCoverage::linesCovered)).setter(setter(Builder::linesCovered))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("linesCovered").build()).build();
private static final SdkField LINES_MISSED_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("linesMissed").getter(getter(CodeCoverage::linesMissed)).setter(setter(Builder::linesMissed))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("linesMissed").build()).build();
private static final SdkField BRANCH_COVERAGE_PERCENTAGE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("branchCoveragePercentage").getter(getter(CodeCoverage::branchCoveragePercentage))
.setter(setter(Builder::branchCoveragePercentage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("branchCoveragePercentage").build())
.build();
private static final SdkField BRANCHES_COVERED_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("branchesCovered").getter(getter(CodeCoverage::branchesCovered)).setter(setter(Builder::branchesCovered))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("branchesCovered").build()).build();
private static final SdkField BRANCHES_MISSED_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("branchesMissed").getter(getter(CodeCoverage::branchesMissed)).setter(setter(Builder::branchesMissed))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("branchesMissed").build()).build();
private static final SdkField EXPIRED_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("expired").getter(getter(CodeCoverage::expired)).setter(setter(Builder::expired))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("expired").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, REPORT_ARN_FIELD,
FILE_PATH_FIELD, LINE_COVERAGE_PERCENTAGE_FIELD, LINES_COVERED_FIELD, LINES_MISSED_FIELD,
BRANCH_COVERAGE_PERCENTAGE_FIELD, BRANCHES_COVERED_FIELD, BRANCHES_MISSED_FIELD, EXPIRED_FIELD));
private static final long serialVersionUID = 1L;
private final String id;
private final String reportARN;
private final String filePath;
private final Double lineCoveragePercentage;
private final Integer linesCovered;
private final Integer linesMissed;
private final Double branchCoveragePercentage;
private final Integer branchesCovered;
private final Integer branchesMissed;
private final Instant expired;
private CodeCoverage(BuilderImpl builder) {
this.id = builder.id;
this.reportARN = builder.reportARN;
this.filePath = builder.filePath;
this.lineCoveragePercentage = builder.lineCoveragePercentage;
this.linesCovered = builder.linesCovered;
this.linesMissed = builder.linesMissed;
this.branchCoveragePercentage = builder.branchCoveragePercentage;
this.branchesCovered = builder.branchesCovered;
this.branchesMissed = builder.branchesMissed;
this.expired = builder.expired;
}
/**
*
* The identifier of the code coverage report.
*
*
* @return The identifier of the code coverage report.
*/
public final String id() {
return id;
}
/**
*
* The ARN of the report.
*
*
* @return The ARN of the report.
*/
public final String reportARN() {
return reportARN;
}
/**
*
* The path of the test report file.
*
*
* @return The path of the test report file.
*/
public final String filePath() {
return filePath;
}
/**
*
* The percentage of lines that are covered by your tests.
*
*
* @return The percentage of lines that are covered by your tests.
*/
public final Double lineCoveragePercentage() {
return lineCoveragePercentage;
}
/**
*
* The number of lines that are covered by your tests.
*
*
* @return The number of lines that are covered by your tests.
*/
public final Integer linesCovered() {
return linesCovered;
}
/**
*
* The number of lines that are not covered by your tests.
*
*
* @return The number of lines that are not covered by your tests.
*/
public final Integer linesMissed() {
return linesMissed;
}
/**
*
* The percentage of branches that are covered by your tests.
*
*
* @return The percentage of branches that are covered by your tests.
*/
public final Double branchCoveragePercentage() {
return branchCoveragePercentage;
}
/**
*
* The number of conditional branches that are covered by your tests.
*
*
* @return The number of conditional branches that are covered by your tests.
*/
public final Integer branchesCovered() {
return branchesCovered;
}
/**
*
* The number of conditional branches that are not covered by your tests.
*
*
* @return The number of conditional branches that are not covered by your tests.
*/
public final Integer branchesMissed() {
return branchesMissed;
}
/**
*
* The date and time that the tests were run.
*
*
* @return The date and time that the tests were run.
*/
public final Instant expired() {
return expired;
}
@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(id());
hashCode = 31 * hashCode + Objects.hashCode(reportARN());
hashCode = 31 * hashCode + Objects.hashCode(filePath());
hashCode = 31 * hashCode + Objects.hashCode(lineCoveragePercentage());
hashCode = 31 * hashCode + Objects.hashCode(linesCovered());
hashCode = 31 * hashCode + Objects.hashCode(linesMissed());
hashCode = 31 * hashCode + Objects.hashCode(branchCoveragePercentage());
hashCode = 31 * hashCode + Objects.hashCode(branchesCovered());
hashCode = 31 * hashCode + Objects.hashCode(branchesMissed());
hashCode = 31 * hashCode + Objects.hashCode(expired());
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 CodeCoverage)) {
return false;
}
CodeCoverage other = (CodeCoverage) obj;
return Objects.equals(id(), other.id()) && Objects.equals(reportARN(), other.reportARN())
&& Objects.equals(filePath(), other.filePath())
&& Objects.equals(lineCoveragePercentage(), other.lineCoveragePercentage())
&& Objects.equals(linesCovered(), other.linesCovered()) && Objects.equals(linesMissed(), other.linesMissed())
&& Objects.equals(branchCoveragePercentage(), other.branchCoveragePercentage())
&& Objects.equals(branchesCovered(), other.branchesCovered())
&& Objects.equals(branchesMissed(), other.branchesMissed()) && Objects.equals(expired(), other.expired());
}
/**
* 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("CodeCoverage").add("Id", id()).add("ReportARN", reportARN()).add("FilePath", filePath())
.add("LineCoveragePercentage", lineCoveragePercentage()).add("LinesCovered", linesCovered())
.add("LinesMissed", linesMissed()).add("BranchCoveragePercentage", branchCoveragePercentage())
.add("BranchesCovered", branchesCovered()).add("BranchesMissed", branchesMissed()).add("Expired", expired())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "id":
return Optional.ofNullable(clazz.cast(id()));
case "reportARN":
return Optional.ofNullable(clazz.cast(reportARN()));
case "filePath":
return Optional.ofNullable(clazz.cast(filePath()));
case "lineCoveragePercentage":
return Optional.ofNullable(clazz.cast(lineCoveragePercentage()));
case "linesCovered":
return Optional.ofNullable(clazz.cast(linesCovered()));
case "linesMissed":
return Optional.ofNullable(clazz.cast(linesMissed()));
case "branchCoveragePercentage":
return Optional.ofNullable(clazz.cast(branchCoveragePercentage()));
case "branchesCovered":
return Optional.ofNullable(clazz.cast(branchesCovered()));
case "branchesMissed":
return Optional.ofNullable(clazz.cast(branchesMissed()));
case "expired":
return Optional.ofNullable(clazz.cast(expired()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function