software.amazon.awssdk.services.workdocs.model.ResourceMetadata 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.workdocs.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.Consumer;
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;
/**
*
* Describes the metadata of a resource.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ResourceMetadata implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Type")
.getter(getter(ResourceMetadata::typeAsString)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(ResourceMetadata::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField ORIGINAL_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("OriginalName").getter(getter(ResourceMetadata::originalName)).setter(setter(Builder::originalName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginalName").build()).build();
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Id")
.getter(getter(ResourceMetadata::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build();
private static final SdkField VERSION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("VersionId").getter(getter(ResourceMetadata::versionId)).setter(setter(Builder::versionId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VersionId").build()).build();
private static final SdkField OWNER_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Owner").getter(getter(ResourceMetadata::owner)).setter(setter(Builder::owner))
.constructor(UserMetadata::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Owner").build()).build();
private static final SdkField PARENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ParentId").getter(getter(ResourceMetadata::parentId)).setter(setter(Builder::parentId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ParentId").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TYPE_FIELD, NAME_FIELD,
ORIGINAL_NAME_FIELD, ID_FIELD, VERSION_ID_FIELD, OWNER_FIELD, PARENT_ID_FIELD));
private static final long serialVersionUID = 1L;
private final String type;
private final String name;
private final String originalName;
private final String id;
private final String versionId;
private final UserMetadata owner;
private final String parentId;
private ResourceMetadata(BuilderImpl builder) {
this.type = builder.type;
this.name = builder.name;
this.originalName = builder.originalName;
this.id = builder.id;
this.versionId = builder.versionId;
this.owner = builder.owner;
this.parentId = builder.parentId;
}
/**
*
* The type of resource.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link ResourceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of resource.
* @see ResourceType
*/
public final ResourceType type() {
return ResourceType.fromValue(type);
}
/**
*
* The type of resource.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link ResourceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of resource.
* @see ResourceType
*/
public final String typeAsString() {
return type;
}
/**
*
* The name of the resource.
*
*
* @return The name of the resource.
*/
public final String name() {
return name;
}
/**
*
* The original name of the resource before a rename operation.
*
*
* @return The original name of the resource before a rename operation.
*/
public final String originalName() {
return originalName;
}
/**
*
* The ID of the resource.
*
*
* @return The ID of the resource.
*/
public final String id() {
return id;
}
/**
*
* The version ID of the resource. This is an optional field and is filled for action on document version.
*
*
* @return The version ID of the resource. This is an optional field and is filled for action on document version.
*/
public final String versionId() {
return versionId;
}
/**
*
* The owner of the resource.
*
*
* @return The owner of the resource.
*/
public final UserMetadata owner() {
return owner;
}
/**
*
* The parent ID of the resource before a rename operation.
*
*
* @return The parent ID of the resource before a rename operation.
*/
public final String parentId() {
return parentId;
}
@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(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(originalName());
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(versionId());
hashCode = 31 * hashCode + Objects.hashCode(owner());
hashCode = 31 * hashCode + Objects.hashCode(parentId());
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 ResourceMetadata)) {
return false;
}
ResourceMetadata other = (ResourceMetadata) obj;
return Objects.equals(typeAsString(), other.typeAsString()) && Objects.equals(name(), other.name())
&& Objects.equals(originalName(), other.originalName()) && Objects.equals(id(), other.id())
&& Objects.equals(versionId(), other.versionId()) && Objects.equals(owner(), other.owner())
&& Objects.equals(parentId(), other.parentId());
}
/**
* 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("ResourceMetadata").add("Type", typeAsString()).add("Name", name())
.add("OriginalName", originalName()).add("Id", id()).add("VersionId", versionId()).add("Owner", owner())
.add("ParentId", parentId()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "OriginalName":
return Optional.ofNullable(clazz.cast(originalName()));
case "Id":
return Optional.ofNullable(clazz.cast(id()));
case "VersionId":
return Optional.ofNullable(clazz.cast(versionId()));
case "Owner":
return Optional.ofNullable(clazz.cast(owner()));
case "ParentId":
return Optional.ofNullable(clazz.cast(parentId()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function