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

net.moznion.mysql.diff.model.Table Maven / Gradle / Ivy

Go to download

Detect and extract diff between two table declarations from schema of MySQL

There is a newer version: 1.1.0
Show newest version
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("");
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy