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

org.mapfish.print.ExtraPropertyException Maven / Gradle / Ivy

package org.mapfish.print;

import java.util.Collection;
import java.util.Set;

/**
 * Indicates one or more properties are not used either in a config.yaml configuration file or in the request json.
 * @author Jesse on 4/2/14.
 */
public final class ExtraPropertyException extends RuntimeException {
    private final Collection extraProperties;
    private final Set attributeNames;

    /**
     * Constructor.
     *
     * @param message the error message. A textual description of the extra properties. List of names will be appended at the end
     * @param extraProperties the properties that are extra
     * @param attributeNames all the allowed attribute names.
     */
    public ExtraPropertyException(final String message, final Collection extraProperties, final Set attributeNames) {
        super(createMessage(message, extraProperties, attributeNames));
        this.extraProperties = extraProperties;
        this.attributeNames = attributeNames;
    }

    private static String createMessage(final String message, final Collection extraProperties,
                                        final Set attributeNames) {
        StringBuilder missingPropertyMessage = new StringBuilder(message).append("\n").append("Extra Properties: \n");
        for (String extraProperty : extraProperties) {
            missingPropertyMessage.append("\n\t* ").append(extraProperty);
        }
        missingPropertyMessage.append("\n\nAll allowed properties are: \n");
        for (String attributeName : attributeNames) {
            missingPropertyMessage.append("\n\t* ").append(attributeName);
        }
        return missingPropertyMessage.toString();
    }

    public Collection getExtraProperties() {
        return this.extraProperties;
    }

    public Set getAttributeNames() {
        return this.attributeNames;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy