/* * Copyright 2018-2023 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.verifiedpermissions.model; import java.io.Serializable; import javax.annotation.Generated; import com.amazonaws.protocol.StructuredPojo; import com.amazonaws.protocol.ProtocolMarshaller; /** *

* A structure that contains the details for a Cedar policy definition. It includes the policy type, a description, and * a policy body. This is a top level data type used to create a policy. *

*

* This data type is used as a request parameter for the CreatePolicy * operation. This structure must always have either an static or a templateLinked element. *

* * @see AWS API Documentation */ @Generated("com.amazonaws:aws-java-sdk-code-generator") public class PolicyDefinition implements Serializable, Cloneable, StructuredPojo { /** *

* A structure that describes a static policy. An static policy doesn't use a template or allow placeholders for * entities. *

*/ private StaticPolicyDefinition staticValue; /** *

* A structure that describes a policy that was instantiated from a template. The template can specify placeholders * for principal and resource. When you use CreatePolicy * to create a policy from a template, you specify the exact principal and resource to use for the instantiated * policy. *

*/ private TemplateLinkedPolicyDefinition templateLinked; /** *

* A structure that describes a static policy. An static policy doesn't use a template or allow placeholders for * entities. *

* * @param staticValue * A structure that describes a static policy. An static policy doesn't use a template or allow placeholders * for entities. */ public void setStatic(StaticPolicyDefinition staticValue) { this.staticValue = staticValue; } /** *

* A structure that describes a static policy. An static policy doesn't use a template or allow placeholders for * entities. *

* * @return A structure that describes a static policy. An static policy doesn't use a template or allow placeholders * for entities. */ public StaticPolicyDefinition getStatic() { return this.staticValue; } /** *

* A structure that describes a static policy. An static policy doesn't use a template or allow placeholders for * entities. *

* * @param staticValue * A structure that describes a static policy. An static policy doesn't use a template or allow placeholders * for entities. * @return Returns a reference to this object so that method calls can be chained together. */ public PolicyDefinition withStatic(StaticPolicyDefinition staticValue) { setStatic(staticValue); return this; } /** *

* A structure that describes a policy that was instantiated from a template. The template can specify placeholders * for principal and resource. When you use CreatePolicy * to create a policy from a template, you specify the exact principal and resource to use for the instantiated * policy. *

* * @param templateLinked * A structure that describes a policy that was instantiated from a template. The template can specify * placeholders for principal and resource. When you use CreatePolicy to create a policy from a template, you specify the exact principal and resource to use * for the instantiated policy. */ public void setTemplateLinked(TemplateLinkedPolicyDefinition templateLinked) { this.templateLinked = templateLinked; } /** *

* A structure that describes a policy that was instantiated from a template. The template can specify placeholders * for principal and resource. When you use CreatePolicy * to create a policy from a template, you specify the exact principal and resource to use for the instantiated * policy. *

* * @return A structure that describes a policy that was instantiated from a template. The template can specify * placeholders for principal and resource. When you use CreatePolicy to create a policy from a template, you specify the exact principal and resource to use * for the instantiated policy. */ public TemplateLinkedPolicyDefinition getTemplateLinked() { return this.templateLinked; } /** *

* A structure that describes a policy that was instantiated from a template. The template can specify placeholders * for principal and resource. When you use CreatePolicy * to create a policy from a template, you specify the exact principal and resource to use for the instantiated * policy. *

* * @param templateLinked * A structure that describes a policy that was instantiated from a template. The template can specify * placeholders for principal and resource. When you use CreatePolicy to create a policy from a template, you specify the exact principal and resource to use * for the instantiated policy. * @return Returns a reference to this object so that method calls can be chained together. */ public PolicyDefinition withTemplateLinked(TemplateLinkedPolicyDefinition templateLinked) { setTemplateLinked(templateLinked); return this; } /** * 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. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getStatic() != null) sb.append("Static: ").append(getStatic()).append(","); if (getTemplateLinked() != null) sb.append("TemplateLinked: ").append(getTemplateLinked()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof PolicyDefinition == false) return false; PolicyDefinition other = (PolicyDefinition) obj; if (other.getStatic() == null ^ this.getStatic() == null) return false; if (other.getStatic() != null && other.getStatic().equals(this.getStatic()) == false) return false; if (other.getTemplateLinked() == null ^ this.getTemplateLinked() == null) return false; if (other.getTemplateLinked() != null && other.getTemplateLinked().equals(this.getTemplateLinked()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStatic() == null) ? 0 : getStatic().hashCode()); hashCode = prime * hashCode + ((getTemplateLinked() == null) ? 0 : getTemplateLinked().hashCode()); return hashCode; } @Override public PolicyDefinition clone() { try { return (PolicyDefinition) 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.verifiedpermissions.model.transform.PolicyDefinitionMarshaller.getInstance().marshall(this, protocolMarshaller); } }