1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | package Torello.Java; /** * An exception that may be used in conjunction with the Friend-Class / Access-Badge Construct * This Exception-Class is nothing more than a Glorified Version of the {@code java.util.Objects} * construct which is often used - {@code requireNonNull(...)}. * * <BR /><BR />The Friend-Class Construct involves passing a Private-Class as an "Access Token" * in order to ensure that methods and / or constructs are only accessible to classes */ public class FriendClassError extends Error { /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUIDEX> */ protected static final long serialVersionUID = 1; /** This is the message passed to this {@code Error's} Constructor */ public static final String STANDARD_MESSAGE = "Friend Class Error, Access-Badge Token has been passed null."; /** Constructs a new Instance of this Class, using the Default-Message */ public FriendClassError() { super(STANDARD_MESSAGE); } /** * Constructs a new Instance of this Class, using the Default-Message, with a User-Provided * Extra-Message appended to the end. * * @param message The "extra message" to append to the end of the Default-Message */ public FriendClassError(String message) { super(STANDARD_MESSAGE + '\n' + message); } /** * If a {@code null} Access-Token has been passed, then the {@code FriendClassError} throws. * @param accessBadgeAsObj Intended to be the Access-Badge instance that was provided. */ public static final void CHECK_NULL(final Object accessBadgeAsObj) { if (accessBadgeAsObj == null) throw new FriendClassError(); } /** * If a {@code null} Access-Token has been passed, then the {@code FriendClassError} throws. * @param accessBadgeAsObj Intended to be the Access-Badge instance that was provided. * * @param message Requests that a Specialized Message be tacked onto the end of the * Exception-Message */ public static final void CHECK_NULL(final Object accessBadgeAsObj, final String message) { if (accessBadgeAsObj == null) throw new FriendClassError(message); } } |