software.amazon.awssdk.services.databasemigration.model.DatabaseResponse Maven / Gradle / Ivy
Show all versions of databasemigration 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.databasemigration.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
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.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Describes a database in a Fleet Advisor collector inventory.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class DatabaseResponse implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField DATABASE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DatabaseId").getter(getter(DatabaseResponse::databaseId)).setter(setter(Builder::databaseId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DatabaseId").build()).build();
private static final SdkField DATABASE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DatabaseName").getter(getter(DatabaseResponse::databaseName)).setter(setter(Builder::databaseName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DatabaseName").build()).build();
private static final SdkField IP_ADDRESS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("IpAddress").getter(getter(DatabaseResponse::ipAddress)).setter(setter(Builder::ipAddress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IpAddress").build()).build();
private static final SdkField NUMBER_OF_SCHEMAS_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("NumberOfSchemas").getter(getter(DatabaseResponse::numberOfSchemas))
.setter(setter(Builder::numberOfSchemas))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NumberOfSchemas").build()).build();
private static final SdkField SERVER_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Server")
.getter(getter(DatabaseResponse::server)).setter(setter(Builder::server))
.constructor(ServerShortInfoResponse::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Server").build()).build();
private static final SdkField SOFTWARE_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("SoftwareDetails")
.getter(getter(DatabaseResponse::softwareDetails)).setter(setter(Builder::softwareDetails))
.constructor(DatabaseInstanceSoftwareDetailsResponse::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SoftwareDetails").build()).build();
private static final SdkField> COLLECTORS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Collectors")
.getter(getter(DatabaseResponse::collectors))
.setter(setter(Builder::collectors))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Collectors").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(CollectorShortInfoResponse::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DATABASE_ID_FIELD,
DATABASE_NAME_FIELD, IP_ADDRESS_FIELD, NUMBER_OF_SCHEMAS_FIELD, SERVER_FIELD, SOFTWARE_DETAILS_FIELD,
COLLECTORS_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final String databaseId;
private final String databaseName;
private final String ipAddress;
private final Long numberOfSchemas;
private final ServerShortInfoResponse server;
private final DatabaseInstanceSoftwareDetailsResponse softwareDetails;
private final List collectors;
private DatabaseResponse(BuilderImpl builder) {
this.databaseId = builder.databaseId;
this.databaseName = builder.databaseName;
this.ipAddress = builder.ipAddress;
this.numberOfSchemas = builder.numberOfSchemas;
this.server = builder.server;
this.softwareDetails = builder.softwareDetails;
this.collectors = builder.collectors;
}
/**
*
* The ID of a database in a Fleet Advisor collector inventory.
*
*
* @return The ID of a database in a Fleet Advisor collector inventory.
*/
public final String databaseId() {
return databaseId;
}
/**
*
* The name of a database in a Fleet Advisor collector inventory.
*
*
* @return The name of a database in a Fleet Advisor collector inventory.
*/
public final String databaseName() {
return databaseName;
}
/**
*
* The IP address of a database in a Fleet Advisor collector inventory.
*
*
* @return The IP address of a database in a Fleet Advisor collector inventory.
*/
public final String ipAddress() {
return ipAddress;
}
/**
*
* The number of schemas in a Fleet Advisor collector inventory database.
*
*
* @return The number of schemas in a Fleet Advisor collector inventory database.
*/
public final Long numberOfSchemas() {
return numberOfSchemas;
}
/**
*
* The server name of a database in a Fleet Advisor collector inventory.
*
*
* @return The server name of a database in a Fleet Advisor collector inventory.
*/
public final ServerShortInfoResponse server() {
return server;
}
/**
*
* The software details of a database in a Fleet Advisor collector inventory, such as database engine and version.
*
*
* @return The software details of a database in a Fleet Advisor collector inventory, such as database engine and
* version.
*/
public final DatabaseInstanceSoftwareDetailsResponse softwareDetails() {
return softwareDetails;
}
/**
* For responses, this returns true if the service returned a value for the Collectors property. This DOES NOT check
* that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is
* useful because the SDK will never return a null collection or map, but you may need to differentiate between the
* service returning nothing (or null) and the service returning an empty collection or map. For requests, this
* returns true if a value for the property was specified in the request builder, and false if a value was not
* specified.
*/
public final boolean hasCollectors() {
return collectors != null && !(collectors instanceof SdkAutoConstructList);
}
/**
*
* A list of collectors associated with the database.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasCollectors} method.
*
*
* @return A list of collectors associated with the database.
*/
public final List collectors() {
return collectors;
}
@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(databaseId());
hashCode = 31 * hashCode + Objects.hashCode(databaseName());
hashCode = 31 * hashCode + Objects.hashCode(ipAddress());
hashCode = 31 * hashCode + Objects.hashCode(numberOfSchemas());
hashCode = 31 * hashCode + Objects.hashCode(server());
hashCode = 31 * hashCode + Objects.hashCode(softwareDetails());
hashCode = 31 * hashCode + Objects.hashCode(hasCollectors() ? collectors() : null);
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 DatabaseResponse)) {
return false;
}
DatabaseResponse other = (DatabaseResponse) obj;
return Objects.equals(databaseId(), other.databaseId()) && Objects.equals(databaseName(), other.databaseName())
&& Objects.equals(ipAddress(), other.ipAddress()) && Objects.equals(numberOfSchemas(), other.numberOfSchemas())
&& Objects.equals(server(), other.server()) && Objects.equals(softwareDetails(), other.softwareDetails())
&& hasCollectors() == other.hasCollectors() && Objects.equals(collectors(), other.collectors());
}
/**
* 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("DatabaseResponse").add("DatabaseId", databaseId()).add("DatabaseName", databaseName())
.add("IpAddress", ipAddress()).add("NumberOfSchemas", numberOfSchemas()).add("Server", server())
.add("SoftwareDetails", softwareDetails()).add("Collectors", hasCollectors() ? collectors() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "DatabaseId":
return Optional.ofNullable(clazz.cast(databaseId()));
case "DatabaseName":
return Optional.ofNullable(clazz.cast(databaseName()));
case "IpAddress":
return Optional.ofNullable(clazz.cast(ipAddress()));
case "NumberOfSchemas":
return Optional.ofNullable(clazz.cast(numberOfSchemas()));
case "Server":
return Optional.ofNullable(clazz.cast(server()));
case "SoftwareDetails":
return Optional.ofNullable(clazz.cast(softwareDetails()));
case "Collectors":
return Optional.ofNullable(clazz.cast(collectors()));
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("DatabaseId", DATABASE_ID_FIELD);
map.put("DatabaseName", DATABASE_NAME_FIELD);
map.put("IpAddress", IP_ADDRESS_FIELD);
map.put("NumberOfSchemas", NUMBER_OF_SCHEMAS_FIELD);
map.put("Server", SERVER_FIELD);
map.put("SoftwareDetails", SOFTWARE_DETAILS_FIELD);
map.put("Collectors", COLLECTORS_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function