software.amazon.awssdk.services.iot.model.DescribeCustomMetricResponse Maven / Gradle / Ivy
Show all versions of iot 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.iot.model;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class DescribeCustomMetricResponse extends IotResponse implements
ToCopyableBuilder {
private static final SdkField METRIC_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("metricName").getter(getter(DescribeCustomMetricResponse::metricName))
.setter(setter(Builder::metricName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("metricName").build()).build();
private static final SdkField METRIC_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("metricArn").getter(getter(DescribeCustomMetricResponse::metricArn)).setter(setter(Builder::metricArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("metricArn").build()).build();
private static final SdkField METRIC_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("metricType").getter(getter(DescribeCustomMetricResponse::metricTypeAsString))
.setter(setter(Builder::metricType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("metricType").build()).build();
private static final SdkField DISPLAY_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("displayName").getter(getter(DescribeCustomMetricResponse::displayName))
.setter(setter(Builder::displayName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("displayName").build()).build();
private static final SdkField CREATION_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("creationDate").getter(getter(DescribeCustomMetricResponse::creationDate))
.setter(setter(Builder::creationDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("creationDate").build()).build();
private static final SdkField LAST_MODIFIED_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("lastModifiedDate").getter(getter(DescribeCustomMetricResponse::lastModifiedDate))
.setter(setter(Builder::lastModifiedDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lastModifiedDate").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(METRIC_NAME_FIELD,
METRIC_ARN_FIELD, METRIC_TYPE_FIELD, DISPLAY_NAME_FIELD, CREATION_DATE_FIELD, LAST_MODIFIED_DATE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private final String metricName;
private final String metricArn;
private final String metricType;
private final String displayName;
private final Instant creationDate;
private final Instant lastModifiedDate;
private DescribeCustomMetricResponse(BuilderImpl builder) {
super(builder);
this.metricName = builder.metricName;
this.metricArn = builder.metricArn;
this.metricType = builder.metricType;
this.displayName = builder.displayName;
this.creationDate = builder.creationDate;
this.lastModifiedDate = builder.lastModifiedDate;
}
/**
*
* The name of the custom metric.
*
*
* @return The name of the custom metric.
*/
public final String metricName() {
return metricName;
}
/**
*
* The Amazon Resource Number (ARN) of the custom metric.
*
*
* @return The Amazon Resource Number (ARN) of the custom metric.
*/
public final String metricArn() {
return metricArn;
}
/**
*
* The type of the custom metric.
*
*
*
* The type number
only takes a single metric value as an input, but while submitting the metrics value
* in the DeviceMetrics report, it must be passed as an array with a single value.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #metricType} will
* return {@link CustomMetricType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #metricTypeAsString}.
*
*
* @return The type of the custom metric.
*
* The type number
only takes a single metric value as an input, but while submitting the
* metrics value in the DeviceMetrics report, it must be passed as an array with a single value.
*
* @see CustomMetricType
*/
public final CustomMetricType metricType() {
return CustomMetricType.fromValue(metricType);
}
/**
*
* The type of the custom metric.
*
*
*
* The type number
only takes a single metric value as an input, but while submitting the metrics value
* in the DeviceMetrics report, it must be passed as an array with a single value.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #metricType} will
* return {@link CustomMetricType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #metricTypeAsString}.
*
*
* @return The type of the custom metric.
*
* The type number
only takes a single metric value as an input, but while submitting the
* metrics value in the DeviceMetrics report, it must be passed as an array with a single value.
*
* @see CustomMetricType
*/
public final String metricTypeAsString() {
return metricType;
}
/**
*
* Field represents a friendly name in the console for the custom metric; doesn't have to be unique. Don't use this
* name as the metric identifier in the device metric report. Can be updated.
*
*
* @return Field represents a friendly name in the console for the custom metric; doesn't have to be unique. Don't
* use this name as the metric identifier in the device metric report. Can be updated.
*/
public final String displayName() {
return displayName;
}
/**
*
* The creation date of the custom metric in milliseconds since epoch.
*
*
* @return The creation date of the custom metric in milliseconds since epoch.
*/
public final Instant creationDate() {
return creationDate;
}
/**
*
* The time the custom metric was last modified in milliseconds since epoch.
*
*
* @return The time the custom metric was last modified in milliseconds since epoch.
*/
public final Instant lastModifiedDate() {
return lastModifiedDate;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(metricName());
hashCode = 31 * hashCode + Objects.hashCode(metricArn());
hashCode = 31 * hashCode + Objects.hashCode(metricTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(displayName());
hashCode = 31 * hashCode + Objects.hashCode(creationDate());
hashCode = 31 * hashCode + Objects.hashCode(lastModifiedDate());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DescribeCustomMetricResponse)) {
return false;
}
DescribeCustomMetricResponse other = (DescribeCustomMetricResponse) obj;
return Objects.equals(metricName(), other.metricName()) && Objects.equals(metricArn(), other.metricArn())
&& Objects.equals(metricTypeAsString(), other.metricTypeAsString())
&& Objects.equals(displayName(), other.displayName()) && Objects.equals(creationDate(), other.creationDate())
&& Objects.equals(lastModifiedDate(), other.lastModifiedDate());
}
/**
* 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("DescribeCustomMetricResponse").add("MetricName", metricName()).add("MetricArn", metricArn())
.add("MetricType", metricTypeAsString()).add("DisplayName", displayName()).add("CreationDate", creationDate())
.add("LastModifiedDate", lastModifiedDate()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "metricName":
return Optional.ofNullable(clazz.cast(metricName()));
case "metricArn":
return Optional.ofNullable(clazz.cast(metricArn()));
case "metricType":
return Optional.ofNullable(clazz.cast(metricTypeAsString()));
case "displayName":
return Optional.ofNullable(clazz.cast(displayName()));
case "creationDate":
return Optional.ofNullable(clazz.cast(creationDate()));
case "lastModifiedDate":
return Optional.ofNullable(clazz.cast(lastModifiedDate()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("metricName", METRIC_NAME_FIELD);
map.put("metricArn", METRIC_ARN_FIELD);
map.put("metricType", METRIC_TYPE_FIELD);
map.put("displayName", DISPLAY_NAME_FIELD);
map.put("creationDate", CREATION_DATE_FIELD);
map.put("lastModifiedDate", LAST_MODIFIED_DATE_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function