
software.amazon.awssdk.services.xray.model.SamplingStatisticsDocument 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.xray.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;
/**
*
* Request sampling results for a single rule from a service. Results are for the last 10 seconds unless the service has
* been assigned a longer reporting interval after a previous call to GetSamplingTargets.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SamplingStatisticsDocument implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField RULE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(SamplingStatisticsDocument::ruleName)).setter(setter(Builder::ruleName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuleName").build()).build();
private static final SdkField CLIENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(SamplingStatisticsDocument::clientID)).setter(setter(Builder::clientID))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClientID").build()).build();
private static final SdkField TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(SamplingStatisticsDocument::timestamp)).setter(setter(Builder::timestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Timestamp").build()).build();
private static final SdkField REQUEST_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(SamplingStatisticsDocument::requestCount)).setter(setter(Builder::requestCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RequestCount").build()).build();
private static final SdkField SAMPLED_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(SamplingStatisticsDocument::sampledCount)).setter(setter(Builder::sampledCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SampledCount").build()).build();
private static final SdkField BORROW_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(SamplingStatisticsDocument::borrowCount)).setter(setter(Builder::borrowCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BorrowCount").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RULE_NAME_FIELD,
CLIENT_ID_FIELD, TIMESTAMP_FIELD, REQUEST_COUNT_FIELD, SAMPLED_COUNT_FIELD, BORROW_COUNT_FIELD));
private static final long serialVersionUID = 1L;
private final String ruleName;
private final String clientID;
private final Instant timestamp;
private final Integer requestCount;
private final Integer sampledCount;
private final Integer borrowCount;
private SamplingStatisticsDocument(BuilderImpl builder) {
this.ruleName = builder.ruleName;
this.clientID = builder.clientID;
this.timestamp = builder.timestamp;
this.requestCount = builder.requestCount;
this.sampledCount = builder.sampledCount;
this.borrowCount = builder.borrowCount;
}
/**
*
* The name of the sampling rule.
*
*
* @return The name of the sampling rule.
*/
public String ruleName() {
return ruleName;
}
/**
*
* A unique identifier for the service in hexadecimal.
*
*
* @return A unique identifier for the service in hexadecimal.
*/
public String clientID() {
return clientID;
}
/**
*
* The current time.
*
*
* @return The current time.
*/
public Instant timestamp() {
return timestamp;
}
/**
*
* The number of requests that matched the rule.
*
*
* @return The number of requests that matched the rule.
*/
public Integer requestCount() {
return requestCount;
}
/**
*
* The number of requests recorded.
*
*
* @return The number of requests recorded.
*/
public Integer sampledCount() {
return sampledCount;
}
/**
*
* The number of requests recorded with borrowed reservoir quota.
*
*
* @return The number of requests recorded with borrowed reservoir quota.
*/
public Integer borrowCount() {
return borrowCount;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(ruleName());
hashCode = 31 * hashCode + Objects.hashCode(clientID());
hashCode = 31 * hashCode + Objects.hashCode(timestamp());
hashCode = 31 * hashCode + Objects.hashCode(requestCount());
hashCode = 31 * hashCode + Objects.hashCode(sampledCount());
hashCode = 31 * hashCode + Objects.hashCode(borrowCount());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SamplingStatisticsDocument)) {
return false;
}
SamplingStatisticsDocument other = (SamplingStatisticsDocument) obj;
return Objects.equals(ruleName(), other.ruleName()) && Objects.equals(clientID(), other.clientID())
&& Objects.equals(timestamp(), other.timestamp()) && Objects.equals(requestCount(), other.requestCount())
&& Objects.equals(sampledCount(), other.sampledCount()) && Objects.equals(borrowCount(), other.borrowCount());
}
/**
* 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 String toString() {
return ToString.builder("SamplingStatisticsDocument").add("RuleName", ruleName()).add("ClientID", clientID())
.add("Timestamp", timestamp()).add("RequestCount", requestCount()).add("SampledCount", sampledCount())
.add("BorrowCount", borrowCount()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "RuleName":
return Optional.ofNullable(clazz.cast(ruleName()));
case "ClientID":
return Optional.ofNullable(clazz.cast(clientID()));
case "Timestamp":
return Optional.ofNullable(clazz.cast(timestamp()));
case "RequestCount":
return Optional.ofNullable(clazz.cast(requestCount()));
case "SampledCount":
return Optional.ofNullable(clazz.cast(sampledCount()));
case "BorrowCount":
return Optional.ofNullable(clazz.cast(borrowCount()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy