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

de.invation.code.toval.properties.PropertyException Maven / Gradle / Ivy

Go to download

TOVAL comprises a set of java classes for common programming issues. It includes utils for arrays, lists, sets and collections for convenient handling and modification, but also support for mathematic definitions concerning logic (clauses + resolution) together with some algorithms for permutations, powersets and resolution. Additionally it contains a number of types for multisets, matrices with object keys and much more.

The newest version!
package de.invation.code.toval.properties;

public class PropertyException extends Exception {

    private static final long serialVersionUID = 1555494643930159891L;

    private final String messageFormat = "Invalid property [%s]: %s";
    private final String extendedMessageFormat = "Invalid property [%s]: %s, %s";
    private String property = null;
    private String value = null;
    private String notification = null;

    public PropertyException(Object property, Object value) {
        super();
        this.property = property.toString();
        if (value != null) {
            this.value = value.toString();
        }
    }
    
    public PropertyException(Object property, Object value, Throwable cause) {
        super(cause);
        this.property = property.toString();
        if (value != null) {
            this.value = value.toString();
        }
    }
    
    public PropertyException(Object property, Object value, String notification, Throwable cause) {
        this(property, value, cause);
        this.notification = notification;
    }

    public PropertyException(Object property, Object value, String notification) {
        this(property, value);
        this.notification = notification;
    }

    @Override
    public String getMessage() {
        if (notification == null) {
            return String.format(messageFormat, property, value);
        } else {
            return String.format(extendedMessageFormat, property, value, notification);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy