forked from aws/aws-cryptographic-material-providers-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: re-polymorph to gain OpaqueWithText (aws#970)
* chore: re-polymorph to gain OpaqueWithText
- Loading branch information
1 parent
1312493
commit 697b110
Showing
46 changed files
with
1,276 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
180 changes: 180 additions & 0 deletions
180
...ain/smithy-generated/software/amazon/cryptography/keystore/model/OpaqueWithTextError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten. | ||
package software.amazon.cryptography.keystore.model; | ||
|
||
public class OpaqueWithTextError extends RuntimeException { | ||
|
||
/** | ||
* The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed. | ||
*/ | ||
private final Object obj; | ||
|
||
/** | ||
* The text equivalent of obj. | ||
*/ | ||
private final String objMessage; | ||
|
||
protected OpaqueWithTextError(BuilderImpl builder) { | ||
super(messageFromBuilder(builder), builder.cause()); | ||
this.obj = builder.obj(); | ||
this.objMessage = builder.objMessage(); | ||
} | ||
|
||
private static String messageFromBuilder(Builder builder) { | ||
if (builder.message() != null) { | ||
return builder.message(); | ||
} | ||
if (builder.cause() != null) { | ||
return builder.cause().getMessage(); | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* See {@link Throwable#getMessage()}. | ||
*/ | ||
public String message() { | ||
return this.getMessage(); | ||
} | ||
|
||
/** | ||
* See {@link Throwable#getCause()}. | ||
*/ | ||
public Throwable cause() { | ||
return this.getCause(); | ||
} | ||
|
||
/** | ||
* @return The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed. | ||
*/ | ||
public Object obj() { | ||
return this.obj; | ||
} | ||
|
||
/** | ||
* @return The text equivalent of obj. | ||
*/ | ||
public String objMessage() { | ||
return this.objMessage; | ||
} | ||
|
||
public Builder toBuilder() { | ||
return new BuilderImpl(this); | ||
} | ||
|
||
public static Builder builder() { | ||
return new BuilderImpl(); | ||
} | ||
|
||
public interface Builder { | ||
/** | ||
* @param message The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method. | ||
*/ | ||
Builder message(String message); | ||
|
||
/** | ||
* @return The detailed message. The detail message is saved for later retrieval by the {@link #getMessage()} method. | ||
*/ | ||
String message(); | ||
|
||
/** | ||
* @param cause The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.) | ||
*/ | ||
Builder cause(Throwable cause); | ||
|
||
/** | ||
* @return The cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.) | ||
*/ | ||
Throwable cause(); | ||
|
||
/** | ||
* @param obj The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed. | ||
*/ | ||
Builder obj(Object obj); | ||
|
||
/** | ||
* @return The unexpected object encountered. It MIGHT BE an Exception, but that is not guaranteed. | ||
*/ | ||
Object obj(); | ||
|
||
/** | ||
* @param objMessage The text equivalent of obj. | ||
*/ | ||
Builder objMessage(String objMessage); | ||
|
||
/** | ||
* @return The text equivalent of obj. | ||
*/ | ||
String objMessage(); | ||
|
||
OpaqueWithTextError build(); | ||
} | ||
|
||
static class BuilderImpl implements Builder { | ||
|
||
protected String message; | ||
|
||
protected Throwable cause; | ||
|
||
protected Object obj; | ||
|
||
protected String objMessage; | ||
|
||
protected BuilderImpl() {} | ||
|
||
protected BuilderImpl(OpaqueWithTextError model) { | ||
this.cause = model.getCause(); | ||
this.message = model.getMessage(); | ||
this.obj = model.obj(); | ||
this.objMessage = model.objMessage(); | ||
} | ||
|
||
public Builder message(String message) { | ||
this.message = message; | ||
return this; | ||
} | ||
|
||
public String message() { | ||
return this.message; | ||
} | ||
|
||
public Builder cause(Throwable cause) { | ||
this.cause = cause; | ||
return this; | ||
} | ||
|
||
public Throwable cause() { | ||
return this.cause; | ||
} | ||
|
||
public Builder obj(Object obj) { | ||
this.obj = obj; | ||
return this; | ||
} | ||
|
||
public Object obj() { | ||
return this.obj; | ||
} | ||
|
||
public Builder objMessage(String objMessage) { | ||
this.objMessage = objMessage; | ||
return this; | ||
} | ||
|
||
public String objMessage() { | ||
return this.objMessage; | ||
} | ||
|
||
public OpaqueWithTextError build() { | ||
if ( | ||
this.obj != null && this.cause == null && this.obj instanceof Throwable | ||
) { | ||
this.cause = (Throwable) this.obj; | ||
} else if (this.obj == null && this.cause != null) { | ||
this.obj = this.cause; | ||
} | ||
return new OpaqueWithTextError(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.