All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.hargrave.configuration.KeyException Maven / Gradle / Ivy

The newest version!
package info.hargrave.configuration;

/**
 * Represents an exception occurring in relation to keys/values
 * Date: 10/25/13
 * Time: 8:49 AM
 */
public class KeyException extends Exception {

    private final String exceptedKey;

    private final Object exceptedValue;

    /**
     * Default constructor
     * @param key   key related to by the exception -- this is always required
     * @param value value related to by the exception, can be null
     * @param message message
     */
    public KeyException(String message, String key, Object value){
        super(message);
        exceptedKey = key;
        exceptedValue = value;
    }

    /**
     * Instantiate the exception with a null (empty) value
     * @param key key related to by the exception
     * @param message message
     */
    public KeyException(String message, String key){
        this(message, key, null);
    }

    /**
     * Get the key related to the exception
     * @return key
     */
    public String getKey(){
        return exceptedKey;
    }

    /**
     * Get the value related to the exception
     * @return value
     */
    public Object getValue(){
        return exceptedValue;
    }

    /**
     * Get whether or not there is a value related to the exception
     * @return value
     */
    public boolean hasValue(){
        return exceptedValue != null;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy