/*
 * Copyright (c) 2004-2017, by Alex Leigh.
 * All rights reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 */

package lc.mecha.lang;

/**
 * An object that implements the <code>Fault</code> interface is one that is
 * capable of being in a faulted state which may be resolved through the use of
 * a fault handler.
 *
 * @author Alex Leigh
 */

public interface Fault {
    /**
     * Clear the fault status of this object; the object is then no longer said
     * to be faulted and further calls to willRead() will have no effect.
     */

    void clearFault();

    /**
     * Return the fault handler (if any) currently associated with this object.
     *
     * @return
     */
    FaultHandler faultHandler();

    /**
     * Returns true of the object is currently faulted, otherwise, returns
     * false.
     *
     * @return
     */
    boolean isFault();

    /**
     * Turn this object into a faulted object, which can be resolved using the
     * provided fault handler.
     *
     * @param handler
     */
    void turnIntoFault(FaultHandler handler);

    /**
     * Indicate that a consumer is going to read a property from this object.
     * This should cause the object to fire the fault handler to ready the
     * object for reading.
     */
    void willRead();
}
