net.moznion.mysql.diff.model.Table Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mysql-diff Show documentation
Show all versions of mysql-diff Show documentation
Detect and extract diff between two table declarations from schema of MySQL
package net.moznion.mysql.diff.model;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@Getter
public class Table {
private final String tableName;
private final List primaryKeys;
private final List uniqueKeys;
private final List keys;
private final List columns;
private final String content;
@Setter
@Accessors(fluent = true)
public static class Builder {
private String tableName;
private List primaryKeys;
private List uniqueKeys;
private List keys;
private List columns;
private String content;
public Builder() {}
public Table build() {
return new Table(this);
}
}
public static Builder builder() {
return new Builder();
}
private Table(Builder builder) {
tableName = Optional.ofNullable(builder.tableName)
.orElseThrow(() -> new IllegalArgumentException("Missing table name"));
primaryKeys = Optional.ofNullable(builder.primaryKeys).orElse(new ArrayList<>());
uniqueKeys = Optional.ofNullable(builder.uniqueKeys).orElse(new ArrayList<>());
keys = Optional.ofNullable(builder.keys).orElse(new ArrayList<>());
columns = Optional.ofNullable(builder.columns).orElse(new ArrayList<>());
content = Optional.ofNullable(builder.content).orElse("");
}
}