software.amazon.awssdk.services.dynamodb.model.Identity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bundle Show documentation
Show all versions of bundle Show documentation
A single bundled dependency that includes all service and dependent JARs with third-party libraries
relocated to different namespaces.
/*
* Copyright 2013-2018 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.dynamodb.model;
import java.util.Objects;
import java.util.Optional;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.protocol.ProtocolMarshaller;
import software.amazon.awssdk.core.protocol.StructuredPojo;
import software.amazon.awssdk.services.dynamodb.transform.IdentityMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Contains details about the type of identity that made the request.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Identity implements StructuredPojo, ToCopyableBuilder {
private final String principalId;
private final String type;
private Identity(BuilderImpl builder) {
this.principalId = builder.principalId;
this.type = builder.type;
}
/**
*
* A unique identifier for the entity that made the call. For Time To Live, the principalId is
* "dynamodb.amazonaws.com".
*
*
* @return A unique identifier for the entity that made the call. For Time To Live, the principalId is
* "dynamodb.amazonaws.com".
*/
public String principalId() {
return principalId;
}
/**
*
* The type of the identity. For Time To Live, the type is "Service".
*
*
* @return The type of the identity. For Time To Live, the type is "Service".
*/
public String type() {
return type;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(principalId());
hashCode = 31 * hashCode + Objects.hashCode(type());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Identity)) {
return false;
}
Identity other = (Identity) obj;
return Objects.equals(principalId(), other.principalId()) && Objects.equals(type(), other.type());
}
@Override
public String toString() {
return ToString.builder("Identity").add("PrincipalId", principalId()).add("Type", type()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "PrincipalId":
return Optional.ofNullable(clazz.cast(principalId()));
case "Type":
return Optional.ofNullable(clazz.cast(type()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
IdentityMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* A unique identifier for the entity that made the call. For Time To Live, the principalId is
* "dynamodb.amazonaws.com".
*
*
* @param principalId
* A unique identifier for the entity that made the call. For Time To Live, the principalId is
* "dynamodb.amazonaws.com".
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder principalId(String principalId);
/**
*
* The type of the identity. For Time To Live, the type is "Service".
*
*
* @param type
* The type of the identity. For Time To Live, the type is "Service".
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder type(String type);
}
static final class BuilderImpl implements Builder {
private String principalId;
private String type;
private BuilderImpl() {
}
private BuilderImpl(Identity model) {
principalId(model.principalId);
type(model.type);
}
public final String getPrincipalId() {
return principalId;
}
@Override
public final Builder principalId(String principalId) {
this.principalId = principalId;
return this;
}
public final void setPrincipalId(String principalId) {
this.principalId = principalId;
}
public final String getType() {
return type;
}
@Override
public final Builder type(String type) {
this.type = type;
return this;
}
public final void setType(String type) {
this.type = type;
}
@Override
public Identity build() {
return new Identity(this);
}
}
}