software.amazon.awssdk.services.timestreamwrite.model.Database Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timestreamwrite Show documentation
Show all versions of timestreamwrite Show documentation
The AWS Java SDK for Timestream Write module holds the client classes that are used for
communicating with Timestream Write.
/*
* 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.timestreamwrite.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;
/**
*
* A top-level container for a table. Databases and tables are the fundamental management concepts in Amazon Timestream.
* All tables in a database are encrypted with the same KMS key.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Database implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Arn")
.getter(getter(Database::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Arn").build()).build();
private static final SdkField DATABASE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DatabaseName").getter(getter(Database::databaseName)).setter(setter(Builder::databaseName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DatabaseName").build()).build();
private static final SdkField TABLE_COUNT_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("TableCount").getter(getter(Database::tableCount)).setter(setter(Builder::tableCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TableCount").build()).build();
private static final SdkField KMS_KEY_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("KmsKeyId").getter(getter(Database::kmsKeyId)).setter(setter(Builder::kmsKeyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KmsKeyId").build()).build();
private static final SdkField CREATION_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreationTime").getter(getter(Database::creationTime)).setter(setter(Builder::creationTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreationTime").build()).build();
private static final SdkField LAST_UPDATED_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastUpdatedTime").getter(getter(Database::lastUpdatedTime)).setter(setter(Builder::lastUpdatedTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastUpdatedTime").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ARN_FIELD,
DATABASE_NAME_FIELD, TABLE_COUNT_FIELD, KMS_KEY_ID_FIELD, CREATION_TIME_FIELD, LAST_UPDATED_TIME_FIELD));
private static final long serialVersionUID = 1L;
private final String arn;
private final String databaseName;
private final Long tableCount;
private final String kmsKeyId;
private final Instant creationTime;
private final Instant lastUpdatedTime;
private Database(BuilderImpl builder) {
this.arn = builder.arn;
this.databaseName = builder.databaseName;
this.tableCount = builder.tableCount;
this.kmsKeyId = builder.kmsKeyId;
this.creationTime = builder.creationTime;
this.lastUpdatedTime = builder.lastUpdatedTime;
}
/**
*
* The Amazon Resource Name that uniquely identifies this database.
*
*
* @return The Amazon Resource Name that uniquely identifies this database.
*/
public final String arn() {
return arn;
}
/**
*
* The name of the Timestream database.
*
*
* @return The name of the Timestream database.
*/
public final String databaseName() {
return databaseName;
}
/**
*
* The total number of tables found within a Timestream database.
*
*
* @return The total number of tables found within a Timestream database.
*/
public final Long tableCount() {
return tableCount;
}
/**
*
* The identifier of the KMS key used to encrypt the data stored in the database.
*
*
* @return The identifier of the KMS key used to encrypt the data stored in the database.
*/
public final String kmsKeyId() {
return kmsKeyId;
}
/**
*
* The time when the database was created, calculated from the Unix epoch time.
*
*
* @return The time when the database was created, calculated from the Unix epoch time.
*/
public final Instant creationTime() {
return creationTime;
}
/**
*
* The last time that this database was updated.
*
*
* @return The last time that this database was updated.
*/
public final Instant lastUpdatedTime() {
return lastUpdatedTime;
}
@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(arn());
hashCode = 31 * hashCode + Objects.hashCode(databaseName());
hashCode = 31 * hashCode + Objects.hashCode(tableCount());
hashCode = 31 * hashCode + Objects.hashCode(kmsKeyId());
hashCode = 31 * hashCode + Objects.hashCode(creationTime());
hashCode = 31 * hashCode + Objects.hashCode(lastUpdatedTime());
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 Database)) {
return false;
}
Database other = (Database) obj;
return Objects.equals(arn(), other.arn()) && Objects.equals(databaseName(), other.databaseName())
&& Objects.equals(tableCount(), other.tableCount()) && Objects.equals(kmsKeyId(), other.kmsKeyId())
&& Objects.equals(creationTime(), other.creationTime())
&& Objects.equals(lastUpdatedTime(), other.lastUpdatedTime());
}
/**
* 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("Database").add("Arn", arn()).add("DatabaseName", databaseName()).add("TableCount", tableCount())
.add("KmsKeyId", kmsKeyId()).add("CreationTime", creationTime()).add("LastUpdatedTime", lastUpdatedTime())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Arn":
return Optional.ofNullable(clazz.cast(arn()));
case "DatabaseName":
return Optional.ofNullable(clazz.cast(databaseName()));
case "TableCount":
return Optional.ofNullable(clazz.cast(tableCount()));
case "KmsKeyId":
return Optional.ofNullable(clazz.cast(kmsKeyId()));
case "CreationTime":
return Optional.ofNullable(clazz.cast(creationTime()));
case "LastUpdatedTime":
return Optional.ofNullable(clazz.cast(lastUpdatedTime()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function