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

* A policy type that defines the voting rules for the network. The rules decide if a proposal is approved. Approval may * be based on criteria such as the percentage of YES votes and the duration of the proposal. The policy * applies to all proposals and is specified when the network is created. *

*

* Applies only to Hyperledger Fabric. *

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

* The percentage of votes among all members that must be YES for a proposal to be approved. For * example, a ThresholdPercentage value of 50 indicates 50%. The * ThresholdComparator determines the precise comparison. If a ThresholdPercentage value * of 50 is specified on a network with 10 members, along with a ThresholdComparator value * of GREATER_THAN, this indicates that 6 YES votes are required for the proposal to be * approved. *

*/ private Integer thresholdPercentage; /** *

* The duration from the time that a proposal is created until it expires. If members cast neither the required * number of YES votes to approve the proposal nor the number of NO votes required to * reject it before the duration expires, the proposal is EXPIRED and ProposalActions * aren't carried out. *

*/ private Integer proposalDurationInHours; /** *

* Determines whether the vote percentage must be greater than the ThresholdPercentage or must be * greater than or equal to the ThreholdPercentage to be approved. *

*/ private String thresholdComparator; /** *

* The percentage of votes among all members that must be YES for a proposal to be approved. For * example, a ThresholdPercentage value of 50 indicates 50%. The * ThresholdComparator determines the precise comparison. If a ThresholdPercentage value * of 50 is specified on a network with 10 members, along with a ThresholdComparator value * of GREATER_THAN, this indicates that 6 YES votes are required for the proposal to be * approved. *

* * @param thresholdPercentage * The percentage of votes among all members that must be YES for a proposal to be approved. For * example, a ThresholdPercentage value of 50 indicates 50%. The * ThresholdComparator determines the precise comparison. If a ThresholdPercentage * value of 50 is specified on a network with 10 members, along with a * ThresholdComparator value of GREATER_THAN, this indicates that 6 * YES votes are required for the proposal to be approved. */ public void setThresholdPercentage(Integer thresholdPercentage) { this.thresholdPercentage = thresholdPercentage; } /** *

* The percentage of votes among all members that must be YES for a proposal to be approved. For * example, a ThresholdPercentage value of 50 indicates 50%. The * ThresholdComparator determines the precise comparison. If a ThresholdPercentage value * of 50 is specified on a network with 10 members, along with a ThresholdComparator value * of GREATER_THAN, this indicates that 6 YES votes are required for the proposal to be * approved. *

* * @return The percentage of votes among all members that must be YES for a proposal to be approved. * For example, a ThresholdPercentage value of 50 indicates 50%. The * ThresholdComparator determines the precise comparison. If a ThresholdPercentage * value of 50 is specified on a network with 10 members, along with a * ThresholdComparator value of GREATER_THAN, this indicates that 6 * YES votes are required for the proposal to be approved. */ public Integer getThresholdPercentage() { return this.thresholdPercentage; } /** *

* The percentage of votes among all members that must be YES for a proposal to be approved. For * example, a ThresholdPercentage value of 50 indicates 50%. The * ThresholdComparator determines the precise comparison. If a ThresholdPercentage value * of 50 is specified on a network with 10 members, along with a ThresholdComparator value * of GREATER_THAN, this indicates that 6 YES votes are required for the proposal to be * approved. *

* * @param thresholdPercentage * The percentage of votes among all members that must be YES for a proposal to be approved. For * example, a ThresholdPercentage value of 50 indicates 50%. The * ThresholdComparator determines the precise comparison. If a ThresholdPercentage * value of 50 is specified on a network with 10 members, along with a * ThresholdComparator value of GREATER_THAN, this indicates that 6 * YES votes are required for the proposal to be approved. * @return Returns a reference to this object so that method calls can be chained together. */ public ApprovalThresholdPolicy withThresholdPercentage(Integer thresholdPercentage) { setThresholdPercentage(thresholdPercentage); return this; } /** *

* The duration from the time that a proposal is created until it expires. If members cast neither the required * number of YES votes to approve the proposal nor the number of NO votes required to * reject it before the duration expires, the proposal is EXPIRED and ProposalActions * aren't carried out. *

* * @param proposalDurationInHours * The duration from the time that a proposal is created until it expires. If members cast neither the * required number of YES votes to approve the proposal nor the number of NO votes * required to reject it before the duration expires, the proposal is EXPIRED and * ProposalActions aren't carried out. */ public void setProposalDurationInHours(Integer proposalDurationInHours) { this.proposalDurationInHours = proposalDurationInHours; } /** *

* The duration from the time that a proposal is created until it expires. If members cast neither the required * number of YES votes to approve the proposal nor the number of NO votes required to * reject it before the duration expires, the proposal is EXPIRED and ProposalActions * aren't carried out. *

* * @return The duration from the time that a proposal is created until it expires. If members cast neither the * required number of YES votes to approve the proposal nor the number of NO votes * required to reject it before the duration expires, the proposal is EXPIRED and * ProposalActions aren't carried out. */ public Integer getProposalDurationInHours() { return this.proposalDurationInHours; } /** *

* The duration from the time that a proposal is created until it expires. If members cast neither the required * number of YES votes to approve the proposal nor the number of NO votes required to * reject it before the duration expires, the proposal is EXPIRED and ProposalActions * aren't carried out. *

* * @param proposalDurationInHours * The duration from the time that a proposal is created until it expires. If members cast neither the * required number of YES votes to approve the proposal nor the number of NO votes * required to reject it before the duration expires, the proposal is EXPIRED and * ProposalActions aren't carried out. * @return Returns a reference to this object so that method calls can be chained together. */ public ApprovalThresholdPolicy withProposalDurationInHours(Integer proposalDurationInHours) { setProposalDurationInHours(proposalDurationInHours); return this; } /** *

* Determines whether the vote percentage must be greater than the ThresholdPercentage or must be * greater than or equal to the ThreholdPercentage to be approved. *

* * @param thresholdComparator * Determines whether the vote percentage must be greater than the ThresholdPercentage or must * be greater than or equal to the ThreholdPercentage to be approved. * @see ThresholdComparator */ public void setThresholdComparator(String thresholdComparator) { this.thresholdComparator = thresholdComparator; } /** *

* Determines whether the vote percentage must be greater than the ThresholdPercentage or must be * greater than or equal to the ThreholdPercentage to be approved. *

* * @return Determines whether the vote percentage must be greater than the ThresholdPercentage or must * be greater than or equal to the ThreholdPercentage to be approved. * @see ThresholdComparator */ public String getThresholdComparator() { return this.thresholdComparator; } /** *

* Determines whether the vote percentage must be greater than the ThresholdPercentage or must be * greater than or equal to the ThreholdPercentage to be approved. *

* * @param thresholdComparator * Determines whether the vote percentage must be greater than the ThresholdPercentage or must * be greater than or equal to the ThreholdPercentage to be approved. * @return Returns a reference to this object so that method calls can be chained together. * @see ThresholdComparator */ public ApprovalThresholdPolicy withThresholdComparator(String thresholdComparator) { setThresholdComparator(thresholdComparator); return this; } /** *

* Determines whether the vote percentage must be greater than the ThresholdPercentage or must be * greater than or equal to the ThreholdPercentage to be approved. *

* * @param thresholdComparator * Determines whether the vote percentage must be greater than the ThresholdPercentage or must * be greater than or equal to the ThreholdPercentage to be approved. * @return Returns a reference to this object so that method calls can be chained together. * @see ThresholdComparator */ public ApprovalThresholdPolicy withThresholdComparator(ThresholdComparator thresholdComparator) { this.thresholdComparator = thresholdComparator.toString(); 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 (getThresholdPercentage() != null) sb.append("ThresholdPercentage: ").append(getThresholdPercentage()).append(","); if (getProposalDurationInHours() != null) sb.append("ProposalDurationInHours: ").append(getProposalDurationInHours()).append(","); if (getThresholdComparator() != null) sb.append("ThresholdComparator: ").append(getThresholdComparator()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ApprovalThresholdPolicy == false) return false; ApprovalThresholdPolicy other = (ApprovalThresholdPolicy) obj; if (other.getThresholdPercentage() == null ^ this.getThresholdPercentage() == null) return false; if (other.getThresholdPercentage() != null && other.getThresholdPercentage().equals(this.getThresholdPercentage()) == false) return false; if (other.getProposalDurationInHours() == null ^ this.getProposalDurationInHours() == null) return false; if (other.getProposalDurationInHours() != null && other.getProposalDurationInHours().equals(this.getProposalDurationInHours()) == false) return false; if (other.getThresholdComparator() == null ^ this.getThresholdComparator() == null) return false; if (other.getThresholdComparator() != null && other.getThresholdComparator().equals(this.getThresholdComparator()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getThresholdPercentage() == null) ? 0 : getThresholdPercentage().hashCode()); hashCode = prime * hashCode + ((getProposalDurationInHours() == null) ? 0 : getProposalDurationInHours().hashCode()); hashCode = prime * hashCode + ((getThresholdComparator() == null) ? 0 : getThresholdComparator().hashCode()); return hashCode; } @Override public ApprovalThresholdPolicy clone() { try { return (ApprovalThresholdPolicy) 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.managedblockchain.model.transform.ApprovalThresholdPolicyMarshaller.getInstance().marshall(this, protocolMarshaller); } }