/* * Copyright 2010-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.iot.model; import java.io.Serializable; /** *

* A collection of authorization information. *

*/ public class AuthInfo implements Serializable { /** *

* The type of action for which the principal is being authorized. *

*

* Constraints:
* Allowed Values: PUBLISH, SUBSCRIBE, RECEIVE, CONNECT */ private String actionType; /** *

* The resources for which the principal is being authorized to perform the * specified action. *

*/ private java.util.List resources; /** *

* The type of action for which the principal is being authorized. *

*

* Constraints:
* Allowed Values: PUBLISH, SUBSCRIBE, RECEIVE, CONNECT * * @return

* The type of action for which the principal is being authorized. *

* @see ActionType */ public String getActionType() { return actionType; } /** *

* The type of action for which the principal is being authorized. *

*

* Constraints:
* Allowed Values: PUBLISH, SUBSCRIBE, RECEIVE, CONNECT * * @param actionType

* The type of action for which the principal is being * authorized. *

* @see ActionType */ public void setActionType(String actionType) { this.actionType = actionType; } /** *

* The type of action for which the principal is being authorized. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Allowed Values: PUBLISH, SUBSCRIBE, RECEIVE, CONNECT * * @param actionType

* The type of action for which the principal is being * authorized. *

* @return A reference to this updated object so that method calls can be * chained together. * @see ActionType */ public AuthInfo withActionType(String actionType) { this.actionType = actionType; return this; } /** *

* The type of action for which the principal is being authorized. *

*

* Constraints:
* Allowed Values: PUBLISH, SUBSCRIBE, RECEIVE, CONNECT * * @param actionType

* The type of action for which the principal is being * authorized. *

* @see ActionType */ public void setActionType(ActionType actionType) { this.actionType = actionType.toString(); } /** *

* The type of action for which the principal is being authorized. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Allowed Values: PUBLISH, SUBSCRIBE, RECEIVE, CONNECT * * @param actionType

* The type of action for which the principal is being * authorized. *

* @return A reference to this updated object so that method calls can be * chained together. * @see ActionType */ public AuthInfo withActionType(ActionType actionType) { this.actionType = actionType.toString(); return this; } /** *

* The resources for which the principal is being authorized to perform the * specified action. *

* * @return

* The resources for which the principal is being authorized to * perform the specified action. *

*/ public java.util.List getResources() { return resources; } /** *

* The resources for which the principal is being authorized to perform the * specified action. *

* * @param resources

* The resources for which the principal is being authorized to * perform the specified action. *

*/ public void setResources(java.util.Collection resources) { if (resources == null) { this.resources = null; return; } this.resources = new java.util.ArrayList(resources); } /** *

* The resources for which the principal is being authorized to perform the * specified action. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param resources

* The resources for which the principal is being authorized to * perform the specified action. *

* @return A reference to this updated object so that method calls can be * chained together. */ public AuthInfo withResources(String... resources) { if (getResources() == null) { this.resources = new java.util.ArrayList(resources.length); } for (String value : resources) { this.resources.add(value); } return this; } /** *

* The resources for which the principal is being authorized to perform the * specified action. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param resources

* The resources for which the principal is being authorized to * perform the specified action. *

* @return A reference to this updated object so that method calls can be * chained together. */ public AuthInfo withResources(java.util.Collection resources) { setResources(resources); 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 (getActionType() != null) sb.append("actionType: " + getActionType() + ","); if (getResources() != null) sb.append("resources: " + getResources()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getActionType() == null) ? 0 : getActionType().hashCode()); hashCode = prime * hashCode + ((getResources() == null) ? 0 : getResources().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof AuthInfo == false) return false; AuthInfo other = (AuthInfo) obj; if (other.getActionType() == null ^ this.getActionType() == null) return false; if (other.getActionType() != null && other.getActionType().equals(this.getActionType()) == false) return false; if (other.getResources() == null ^ this.getResources() == null) return false; if (other.getResources() != null && other.getResources().equals(this.getResources()) == false) return false; return true; } }