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

pl.jalokim.propertiestojson.util.exception.MergeObjectException Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
package pl.jalokim.propertiestojson.util.exception;

import com.google.common.annotations.VisibleForTesting;
import pl.jalokim.propertiestojson.object.AbstractJsonType;
import pl.jalokim.propertiestojson.path.PathMetadata;

import static java.lang.String.format;

public class MergeObjectException extends RuntimeException {
    public MergeObjectException(AbstractJsonType oldJsonElement, AbstractJsonType elementToAdd, PathMetadata currentPathMetadata) {
        this(oldJsonElement.toStringJson(), elementToAdd.toStringJson(), currentPathMetadata);
    }

    @VisibleForTesting
    public MergeObjectException(String oldJsonElementValue, String elementToAddValue, PathMetadata currentPathMetadata) {
        super(format("Cannot merge objects with different types:%n Old object: %s%n New object: %s%n problematic key: '%s'%n with value: %s",
                     oldJsonElementValue, elementToAddValue, currentPathMetadata.getOriginalPropertyKey(), currentPathMetadata.getRawValue()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy