|
| 1 | +// Copyright (c) 2019 Pivotal Software, Inc. All rights reserved. |
| 2 | +// |
| 3 | +// This software, the RabbitMQ Java client library, is triple-licensed under the |
| 4 | +// Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2 |
| 5 | +// ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see |
| 6 | +// LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, |
| 7 | +// please see LICENSE-APACHE2. |
| 8 | +// |
| 9 | +// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, |
| 10 | +// either express or implied. See the LICENSE file for specific language governing |
| 11 | +// rights and limitations of this software. |
| 12 | +// |
| 13 | +// If you have any questions regarding licensing, please contact us at |
| 14 | + |
| 15 | + |
| 16 | +package com.rabbitmq.client.impl; |
| 17 | + |
| 18 | +import com.rabbitmq.client.LongString; |
| 19 | + |
| 20 | +import java.io.IOException; |
| 21 | +import java.util.Objects; |
| 22 | + |
| 23 | +/** |
| 24 | + * Helper for <code>update-secret</code> extension {@link com.rabbitmq.client.Method}. |
| 25 | + * <p> |
| 26 | + * {@link com.rabbitmq.client.Method} classes are usually automatically |
| 27 | + * generated, but providing the class directly is necessary in this case |
| 28 | + * for some internal CI testing jobs running against RabbitMQ 3.7. |
| 29 | + * |
| 30 | + * @since 5.8.0 |
| 31 | + */ |
| 32 | +abstract class UpdateSecretExtension { |
| 33 | + |
| 34 | + static class UpdateSecret extends Method { |
| 35 | + |
| 36 | + private final LongString newSecret; |
| 37 | + private final String reason; |
| 38 | + |
| 39 | + public UpdateSecret(LongString newSecret, String reason) { |
| 40 | + if (newSecret == null) |
| 41 | + throw new IllegalStateException("Invalid configuration: 'newSecret' must be non-null."); |
| 42 | + if (reason == null) |
| 43 | + throw new IllegalStateException("Invalid configuration: 'reason' must be non-null."); |
| 44 | + this.newSecret = newSecret; |
| 45 | + this.reason = reason; |
| 46 | + } |
| 47 | + |
| 48 | + public String getReason() { |
| 49 | + return reason; |
| 50 | + } |
| 51 | + |
| 52 | + public int protocolClassId() { |
| 53 | + return 10; |
| 54 | + } |
| 55 | + |
| 56 | + public int protocolMethodId() { |
| 57 | + return 70; |
| 58 | + } |
| 59 | + |
| 60 | + public String protocolMethodName() { |
| 61 | + return "connection.update-secret"; |
| 62 | + } |
| 63 | + |
| 64 | + public boolean hasContent() { |
| 65 | + return false; |
| 66 | + } |
| 67 | + |
| 68 | + public Object visit(AMQImpl.MethodVisitor visitor) throws IOException { |
| 69 | + return null; |
| 70 | + } |
| 71 | + |
| 72 | + |
| 73 | + @Override |
| 74 | + public boolean equals(Object o) { |
| 75 | + if (this == o) |
| 76 | + return true; |
| 77 | + if (o == null || getClass() != o.getClass()) |
| 78 | + return false; |
| 79 | + UpdateSecret that = (UpdateSecret) o; |
| 80 | + if (!Objects.equals(newSecret, that.newSecret)) |
| 81 | + return false; |
| 82 | + return Objects.equals(reason, that.reason); |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public int hashCode() { |
| 87 | + int result = 0; |
| 88 | + result = 31 * result + (newSecret != null ? newSecret.hashCode() : 0); |
| 89 | + result = 31 * result + (reason != null ? reason.hashCode() : 0); |
| 90 | + return result; |
| 91 | + } |
| 92 | + |
| 93 | + public void appendArgumentDebugStringTo(StringBuilder acc) { |
| 94 | + acc.append("(new-secret=") |
| 95 | + .append(this.newSecret) |
| 96 | + .append(", reason=") |
| 97 | + .append(this.reason) |
| 98 | + .append(")"); |
| 99 | + } |
| 100 | + |
| 101 | + public void writeArgumentsTo(MethodArgumentWriter writer) |
| 102 | + throws IOException { |
| 103 | + writer.writeLongstr(this.newSecret); |
| 104 | + writer.writeShortstr(this.reason); |
| 105 | + } |
| 106 | + } |
| 107 | +} |
| 108 | + |
0 commit comments