io.ebeaninternal.server.deploy.DbMigrationInfo Maven / Gradle / Ivy
package io.ebeaninternal.server.deploy;
import java.util.Collections;
import java.util.List;
import io.ebean.annotation.Platform;
/**
* Class to hold the DDL-migration information that is needed to do correct alters.
*
* @author Roland Praml, FOCONIS AG
*/
public final class DbMigrationInfo {
private final List preAdd;
private final List postAdd;
private final List preAlter;
private final List postAlter;
private final List platforms;
public DbMigrationInfo(String[] preAdd, String[] postAdd, String[] preAlter, String[] postAlter, Platform[] platforms) {
this.preAdd = toList(preAdd);
this.postAdd = toList(postAdd);
this.preAlter = toList(preAlter);
this.postAlter = toList(postAlter);
this.platforms = toList(platforms);
}
private List toList(T[] scripts) {
if (scripts.length == 0) {
return Collections.emptyList();
} else {
return List.of(scripts);
}
}
public List getPreAdd() {
return preAdd;
}
public List getPostAdd() {
return postAdd;
}
public List getPreAlter() {
return preAlter;
}
public List getPostAlter() {
return postAlter;
}
public List getPlatforms() {
return platforms;
}
public String joinPlatforms() {
if (platforms.isEmpty()) {
return null;
} else {
StringBuilder sb = new StringBuilder();
for (Platform p : platforms) {
if (sb.length() > 0) {
sb.append(',');
}
sb.append(p.name().toLowerCase());
}
return sb.toString();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy