001package Torello.Java; 
002
003/**
004 * An exception that may be used in conjunction with the Friend-Class / Access-Badge Construct
005 * This Exception-Class is nothing more than a Glorified Version of the {@code java.util.Objects}
006 * construct which is often used - {@code requireNonNull(...)}.
007 * 
008 * <BR /><BR />The Friend-Class Construct involves passing a Private-Class as an "Access Token" 
009 * in order to ensure that methods and / or constructs are only accessible to classes
010 */
011public class FriendClassError extends Error 
012{
013    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUIDEX> */
014    protected static final long serialVersionUID = 1;
015
016    /** This is the message passed to this {@code Error's} Constructor */
017    public static final String STANDARD_MESSAGE =
018        "Friend Class Error, Access-Badge Token has been passed null.";
019
020    /** Constructs a new Instance of this Class, using the Default-Message */
021    public FriendClassError()
022    { super(STANDARD_MESSAGE); }
023
024    /**
025     * Constructs a new Instance of this Class, using the Default-Message, with a User-Provided 
026     * Extra-Message appended to the end.
027     * 
028     * @param message The "extra message" to append to the end of the Default-Message
029     */
030    public FriendClassError(String message)
031    { super(STANDARD_MESSAGE + '\n' + message); }
032
033    /**
034     * If a {@code null} Access-Token has been passed, then the {@code FriendClassError} throws.
035     * @param accessBadgeAsObj Intended to be the Access-Badge instance that was provided.
036     */
037    public static final void CHECK_NULL(final Object accessBadgeAsObj)
038    { if (accessBadgeAsObj == null) throw new FriendClassError(); }
039
040    /**
041     * If a {@code null} Access-Token has been passed, then the {@code FriendClassError} throws.
042     * @param accessBadgeAsObj Intended to be the Access-Badge instance that was provided.
043     * 
044     * @param message Requests that a Specialized Message be tacked onto the end of the
045     * Exception-Message
046     */
047    public static final void CHECK_NULL(final Object accessBadgeAsObj, final String message)
048    { if (accessBadgeAsObj == null) throw new FriendClassError(message); }
049}