/*
* Copyright 2012-2017 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 com.amazonaws.services.kms.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
* <p>
* A key-value pair. A tag consists of a tag key and a tag value. Tag keys and tag values are both required, but tag
* values can be empty (null) strings.
* </p>
*
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/kms-2014-11-01/Tag" target="_top">AWS API Documentation</a>
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class Tag implements Serializable, Cloneable, StructuredPojo {
/**
* <p>
* The key of the tag.
* </p>
*/
private String tagKey;
/**
* <p>
* The value of the tag.
* </p>
*/
private String tagValue;
/**
* <p>
* The key of the tag.
* </p>
*
* @param tagKey
* The key of the tag.
*/
public void setTagKey(String tagKey) {
this.tagKey = tagKey;
}
/**
* <p>
* The key of the tag.
* </p>
*
* @return The key of the tag.
*/
public String getTagKey() {
return this.tagKey;
}
/**
* <p>
* The key of the tag.
* </p>
*
* @param tagKey
* The key of the tag.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Tag withTagKey(String tagKey) {
setTagKey(tagKey);
return this;
}
/**
* <p>
* The value of the tag.
* </p>
*
* @param tagValue
* The value of the tag.
*/
public void setTagValue(String tagValue) {
this.tagValue = tagValue;
}
/**
* <p>
* The value of the tag.
* </p>
*
* @return The value of the tag.
*/
public String getTagValue() {
return this.tagValue;
}
/**
* <p>
* The value of the tag.
* </p>
*
* @param tagValue
* The value of the tag.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Tag withTagValue(String tagValue) {
setTagValue(tagValue);
return this;
}
/**
* Returns a string representation of this object; useful for testing and debugging.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getTagKey() != null)
sb.append("TagKey: ").append(getTagKey()).append(",");
if (getTagValue() != null)
sb.append("TagValue: ").append(getTagValue());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof Tag == false)
return false;
Tag other = (Tag) obj;
if (other.getTagKey() == null ^ this.getTagKey() == null)
return false;
if (other.getTagKey() != null && other.getTagKey().equals(this.getTagKey()) == false)
return false;
if (other.getTagValue() == null ^ this.getTagValue() == null)
return false;
if (other.getTagValue() != null && other.getTagValue().equals(this.getTagValue()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getTagKey() == null) ? 0 : getTagKey().hashCode());
hashCode = prime * hashCode + ((getTagValue() == null) ? 0 : getTagValue().hashCode());
return hashCode;
}
@Override
public Tag clone() {
try {
return (Tag) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.kms.model.transform.TagMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}