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

name.remal.annotation.ErrorCreatingAnnotationInstanceException Maven / Gradle / Ivy

package name.remal.annotation;

import java.lang.annotation.Annotation;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class ErrorCreatingAnnotationInstanceException extends RuntimeException {

    private static String formatMessage(@NotNull Class type, @Nullable String message) {
        StringBuilder sb = new StringBuilder();
        sb.append("Error creating annotation ").append(type.getName()).append(" instance");
        if (message != null && !message.isEmpty()) {
            sb.append(": ").append(message);
        }
        return sb.toString();
    }

    public ErrorCreatingAnnotationInstanceException(@NotNull Class type) {
        super(formatMessage(type, null));
    }

    public ErrorCreatingAnnotationInstanceException(@NotNull Class type, @NotNull String message) {
        super(formatMessage(type, message));
    }

    public ErrorCreatingAnnotationInstanceException(@NotNull Class type, @NotNull String message, @NotNull Throwable cause) {
        super(formatMessage(type, message), cause);
    }

    public ErrorCreatingAnnotationInstanceException(@NotNull Class type, @NotNull Throwable cause) {
        super(formatMessage(type, null), cause);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy