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

* Represents an API resource. *

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

* The resource's identifier. *

*/ private String id; /** *

* The parent resource's identifier. *

*/ private String parentId; /** *

* The last path segment for this resource. *

*/ private String pathPart; /** *

* The full path for this resource. *

*/ private String path; /** *

* Gets an API resource's method of a given HTTP verb. *

*/ private java.util.Map resourceMethods; /** *

* The resource's identifier. *

* * @param id * The resource's identifier. */ public void setId(String id) { this.id = id; } /** *

* The resource's identifier. *

* * @return The resource's identifier. */ public String getId() { return this.id; } /** *

* The resource's identifier. *

* * @param id * The resource's identifier. * @return Returns a reference to this object so that method calls can be chained together. */ public Resource withId(String id) { setId(id); return this; } /** *

* The parent resource's identifier. *

* * @param parentId * The parent resource's identifier. */ public void setParentId(String parentId) { this.parentId = parentId; } /** *

* The parent resource's identifier. *

* * @return The parent resource's identifier. */ public String getParentId() { return this.parentId; } /** *

* The parent resource's identifier. *

* * @param parentId * The parent resource's identifier. * @return Returns a reference to this object so that method calls can be chained together. */ public Resource withParentId(String parentId) { setParentId(parentId); return this; } /** *

* The last path segment for this resource. *

* * @param pathPart * The last path segment for this resource. */ public void setPathPart(String pathPart) { this.pathPart = pathPart; } /** *

* The last path segment for this resource. *

* * @return The last path segment for this resource. */ public String getPathPart() { return this.pathPart; } /** *

* The last path segment for this resource. *

* * @param pathPart * The last path segment for this resource. * @return Returns a reference to this object so that method calls can be chained together. */ public Resource withPathPart(String pathPart) { setPathPart(pathPart); return this; } /** *

* The full path for this resource. *

* * @param path * The full path for this resource. */ public void setPath(String path) { this.path = path; } /** *

* The full path for this resource. *

* * @return The full path for this resource. */ public String getPath() { return this.path; } /** *

* The full path for this resource. *

* * @param path * The full path for this resource. * @return Returns a reference to this object so that method calls can be chained together. */ public Resource withPath(String path) { setPath(path); return this; } /** *

* Gets an API resource's method of a given HTTP verb. *

* * @return Gets an API resource's method of a given HTTP verb. */ public java.util.Map getResourceMethods() { return resourceMethods; } /** *

* Gets an API resource's method of a given HTTP verb. *

* * @param resourceMethods * Gets an API resource's method of a given HTTP verb. */ public void setResourceMethods(java.util.Map resourceMethods) { this.resourceMethods = resourceMethods; } /** *

* Gets an API resource's method of a given HTTP verb. *

* * @param resourceMethods * Gets an API resource's method of a given HTTP verb. * @return Returns a reference to this object so that method calls can be chained together. */ public Resource withResourceMethods(java.util.Map resourceMethods) { setResourceMethods(resourceMethods); return this; } /** * Add a single ResourceMethods entry * * @see Resource#withResourceMethods * @returns a reference to this object so that method calls can be chained together. */ public Resource addResourceMethodsEntry(String key, Method value) { if (null == this.resourceMethods) { this.resourceMethods = new java.util.HashMap(); } if (this.resourceMethods.containsKey(key)) throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided."); this.resourceMethods.put(key, value); return this; } /** * Removes all the entries added into ResourceMethods. * * @return Returns a reference to this object so that method calls can be chained together. */ public Resource clearResourceMethodsEntries() { this.resourceMethods = null; 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 (getId() != null) sb.append("Id: ").append(getId()).append(","); if (getParentId() != null) sb.append("ParentId: ").append(getParentId()).append(","); if (getPathPart() != null) sb.append("PathPart: ").append(getPathPart()).append(","); if (getPath() != null) sb.append("Path: ").append(getPath()).append(","); if (getResourceMethods() != null) sb.append("ResourceMethods: ").append(getResourceMethods()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Resource == false) return false; Resource other = (Resource) obj; if (other.getId() == null ^ this.getId() == null) return false; if (other.getId() != null && other.getId().equals(this.getId()) == false) return false; if (other.getParentId() == null ^ this.getParentId() == null) return false; if (other.getParentId() != null && other.getParentId().equals(this.getParentId()) == false) return false; if (other.getPathPart() == null ^ this.getPathPart() == null) return false; if (other.getPathPart() != null && other.getPathPart().equals(this.getPathPart()) == false) return false; if (other.getPath() == null ^ this.getPath() == null) return false; if (other.getPath() != null && other.getPath().equals(this.getPath()) == false) return false; if (other.getResourceMethods() == null ^ this.getResourceMethods() == null) return false; if (other.getResourceMethods() != null && other.getResourceMethods().equals(this.getResourceMethods()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getId() == null) ? 0 : getId().hashCode()); hashCode = prime * hashCode + ((getParentId() == null) ? 0 : getParentId().hashCode()); hashCode = prime * hashCode + ((getPathPart() == null) ? 0 : getPathPart().hashCode()); hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode()); hashCode = prime * hashCode + ((getResourceMethods() == null) ? 0 : getResourceMethods().hashCode()); return hashCode; } @Override public Resource clone() { try { return (Resource) 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.apigateway.model.transform.ResourceMarshaller.getInstance().marshall(this, protocolMarshaller); } }