
software.amazon.awssdk.services.shield.model.SummarizedCounter Maven / Gradle / Ivy
/*
* 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.shield.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.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 counter that describes a DDoS attack.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SummarizedCounter implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(SummarizedCounter::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField MAX_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("Max")
.getter(getter(SummarizedCounter::max)).setter(setter(Builder::max))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Max").build()).build();
private static final SdkField AVERAGE_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("Average")
.getter(getter(SummarizedCounter::average)).setter(setter(Builder::average))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Average").build()).build();
private static final SdkField SUM_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("Sum")
.getter(getter(SummarizedCounter::sum)).setter(setter(Builder::sum))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Sum").build()).build();
private static final SdkField N_FIELD = SdkField. builder(MarshallingType.INTEGER).memberName("N")
.getter(getter(SummarizedCounter::n)).setter(setter(Builder::n))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("N").build()).build();
private static final SdkField UNIT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Unit")
.getter(getter(SummarizedCounter::unit)).setter(setter(Builder::unit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Unit").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, MAX_FIELD,
AVERAGE_FIELD, SUM_FIELD, N_FIELD, UNIT_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final Double max;
private final Double average;
private final Double sum;
private final Integer n;
private final String unit;
private SummarizedCounter(BuilderImpl builder) {
this.name = builder.name;
this.max = builder.max;
this.average = builder.average;
this.sum = builder.sum;
this.n = builder.n;
this.unit = builder.unit;
}
/**
*
* The counter name.
*
*
* @return The counter name.
*/
public final String name() {
return name;
}
/**
*
* The maximum value of the counter for a specified time period.
*
*
* @return The maximum value of the counter for a specified time period.
*/
public final Double max() {
return max;
}
/**
*
* The average value of the counter for a specified time period.
*
*
* @return The average value of the counter for a specified time period.
*/
public final Double average() {
return average;
}
/**
*
* The total of counter values for a specified time period.
*
*
* @return The total of counter values for a specified time period.
*/
public final Double sum() {
return sum;
}
/**
*
* The number of counters for a specified time period.
*
*
* @return The number of counters for a specified time period.
*/
public final Integer n() {
return n;
}
/**
*
* The unit of the counters.
*
*
* @return The unit of the counters.
*/
public final String unit() {
return unit;
}
@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(max());
hashCode = 31 * hashCode + Objects.hashCode(average());
hashCode = 31 * hashCode + Objects.hashCode(sum());
hashCode = 31 * hashCode + Objects.hashCode(n());
hashCode = 31 * hashCode + Objects.hashCode(unit());
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 SummarizedCounter)) {
return false;
}
SummarizedCounter other = (SummarizedCounter) obj;
return Objects.equals(name(), other.name()) && Objects.equals(max(), other.max())
&& Objects.equals(average(), other.average()) && Objects.equals(sum(), other.sum())
&& Objects.equals(n(), other.n()) && Objects.equals(unit(), other.unit());
}
/**
* 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("SummarizedCounter").add("Name", name()).add("Max", max()).add("Average", average())
.add("Sum", sum()).add("N", n()).add("Unit", unit()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Max":
return Optional.ofNullable(clazz.cast(max()));
case "Average":
return Optional.ofNullable(clazz.cast(average()));
case "Sum":
return Optional.ofNullable(clazz.cast(sum()));
case "N":
return Optional.ofNullable(clazz.cast(n()));
case "Unit":
return Optional.ofNullable(clazz.cast(unit()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy