org.babyfish.jimmer.sql.exception.DatabaseValidationException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql Show documentation
Show all versions of jimmer-sql Show documentation
A revolutionary ORM framework for both java and kotlin
The newest version!
package org.babyfish.jimmer.sql.exception;
import org.babyfish.jimmer.meta.ImmutableProp;
import org.babyfish.jimmer.meta.ImmutableType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class DatabaseValidationException extends ExecutionException {
private final List- items;
public DatabaseValidationException(List
- items) {
super(message(items));
this.items = Collections.unmodifiableList(
new ArrayList<>(items)
);
}
@NotNull
public List
- getItems() {
return items;
}
private static String message(List
- items) {
StringBuilder builder = new StringBuilder("Failed to validate database: \n");
for (Item item : items) {
builder.append("- ");
if (item.getProp() != null) {
builder.append(item.getProp());
} else {
builder.append(item.getType());
}
builder.append(": ").append(item.getMessage()).append('\n');
}
return builder.toString();
}
public static class Item {
private final ImmutableType type;
private final ImmutableProp prop;
private final String message;
public Item(ImmutableType type, ImmutableProp prop, String message) {
this.type = type;
this.prop = prop;
this.message = message;
}
@NotNull
public ImmutableType getType() {
return type;
}
@Nullable
public ImmutableProp getProp() {
return prop;
}
@NotNull
public String getMessage() {
return message;
}
@Override
public String toString() {
return "Item{" +
"type=" + type +
", prop=" + prop +
", message='" + message + '\'' +
'}';
}
}
}