software.amazon.awssdk.services.forecast.model.WindowSummary Maven / Gradle / Ivy
Show all versions of forecast 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.forecast.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.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;
/**
*
* The metrics for a time range within the evaluation portion of a dataset. This object is part of the
* EvaluationResult object.
*
*
* The TestWindowStart
and TestWindowEnd
parameters are determined by the
* BackTestWindowOffset
parameter of the EvaluationParameters object.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class WindowSummary implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField TEST_WINDOW_START_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("TestWindowStart").getter(getter(WindowSummary::testWindowStart))
.setter(setter(Builder::testWindowStart))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TestWindowStart").build()).build();
private static final SdkField TEST_WINDOW_END_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("TestWindowEnd").getter(getter(WindowSummary::testWindowEnd)).setter(setter(Builder::testWindowEnd))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TestWindowEnd").build()).build();
private static final SdkField ITEM_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ItemCount").getter(getter(WindowSummary::itemCount)).setter(setter(Builder::itemCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ItemCount").build()).build();
private static final SdkField EVALUATION_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("EvaluationType").getter(getter(WindowSummary::evaluationTypeAsString))
.setter(setter(Builder::evaluationType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EvaluationType").build()).build();
private static final SdkField METRICS_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Metrics").getter(getter(WindowSummary::metrics)).setter(setter(Builder::metrics))
.constructor(Metrics::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Metrics").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TEST_WINDOW_START_FIELD,
TEST_WINDOW_END_FIELD, ITEM_COUNT_FIELD, EVALUATION_TYPE_FIELD, METRICS_FIELD));
private static final long serialVersionUID = 1L;
private final Instant testWindowStart;
private final Instant testWindowEnd;
private final Integer itemCount;
private final String evaluationType;
private final Metrics metrics;
private WindowSummary(BuilderImpl builder) {
this.testWindowStart = builder.testWindowStart;
this.testWindowEnd = builder.testWindowEnd;
this.itemCount = builder.itemCount;
this.evaluationType = builder.evaluationType;
this.metrics = builder.metrics;
}
/**
*
* The timestamp that defines the start of the window.
*
*
* @return The timestamp that defines the start of the window.
*/
public final Instant testWindowStart() {
return testWindowStart;
}
/**
*
* The timestamp that defines the end of the window.
*
*
* @return The timestamp that defines the end of the window.
*/
public final Instant testWindowEnd() {
return testWindowEnd;
}
/**
*
* The number of data points within the window.
*
*
* @return The number of data points within the window.
*/
public final Integer itemCount() {
return itemCount;
}
/**
*
* The type of evaluation.
*
*
* -
*
* SUMMARY
- The average metrics across all windows.
*
*
* -
*
* COMPUTED
- The metrics for the specified window.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #evaluationType}
* will return {@link EvaluationType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #evaluationTypeAsString}.
*
*
* @return The type of evaluation.
*
* -
*
* SUMMARY
- The average metrics across all windows.
*
*
* -
*
* COMPUTED
- The metrics for the specified window.
*
*
* @see EvaluationType
*/
public final EvaluationType evaluationType() {
return EvaluationType.fromValue(evaluationType);
}
/**
*
* The type of evaluation.
*
*
* -
*
* SUMMARY
- The average metrics across all windows.
*
*
* -
*
* COMPUTED
- The metrics for the specified window.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #evaluationType}
* will return {@link EvaluationType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #evaluationTypeAsString}.
*
*
* @return The type of evaluation.
*
* -
*
* SUMMARY
- The average metrics across all windows.
*
*
* -
*
* COMPUTED
- The metrics for the specified window.
*
*
* @see EvaluationType
*/
public final String evaluationTypeAsString() {
return evaluationType;
}
/**
*
* Provides metrics used to evaluate the performance of a predictor.
*
*
* @return Provides metrics used to evaluate the performance of a predictor.
*/
public final Metrics metrics() {
return metrics;
}
@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(testWindowStart());
hashCode = 31 * hashCode + Objects.hashCode(testWindowEnd());
hashCode = 31 * hashCode + Objects.hashCode(itemCount());
hashCode = 31 * hashCode + Objects.hashCode(evaluationTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(metrics());
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 WindowSummary)) {
return false;
}
WindowSummary other = (WindowSummary) obj;
return Objects.equals(testWindowStart(), other.testWindowStart())
&& Objects.equals(testWindowEnd(), other.testWindowEnd()) && Objects.equals(itemCount(), other.itemCount())
&& Objects.equals(evaluationTypeAsString(), other.evaluationTypeAsString())
&& Objects.equals(metrics(), other.metrics());
}
/**
* 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("WindowSummary").add("TestWindowStart", testWindowStart()).add("TestWindowEnd", testWindowEnd())
.add("ItemCount", itemCount()).add("EvaluationType", evaluationTypeAsString()).add("Metrics", metrics()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TestWindowStart":
return Optional.ofNullable(clazz.cast(testWindowStart()));
case "TestWindowEnd":
return Optional.ofNullable(clazz.cast(testWindowEnd()));
case "ItemCount":
return Optional.ofNullable(clazz.cast(itemCount()));
case "EvaluationType":
return Optional.ofNullable(clazz.cast(evaluationTypeAsString()));
case "Metrics":
return Optional.ofNullable(clazz.cast(metrics()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function