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

com.rinoto.migramongo.MigraMongoStatus Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package com.rinoto.migramongo;

import java.util.ArrayList;
import java.util.List;

public class MigraMongoStatus {

	public MigrationStatus status;
	public String message;
	public List migrationsApplied = new ArrayList<>();

	public MigraMongoStatus(MigrationStatus status, String message) {
		this.status = status;
		this.message = message;
	}

	public static final MigraMongoStatus ok() {
		return ok("Everything ok");
	}

	public static final MigraMongoStatus ok(String message) {
		return new MigraMongoStatus(MigrationStatus.OK, message);
	}

	public static final MigraMongoStatus error(String errorMessage) {
		return new MigraMongoStatus(MigrationStatus.ERROR, errorMessage);
	}

	public static final MigraMongoStatus inProgress(String message) {
		return new MigraMongoStatus(MigrationStatus.IN_PROGRESS, message);
	}

	public MigraMongoStatus addEntry(MigrationEntry migEntry) {
		migrationsApplied.add(migEntry);
		return this;
	}

	public MigraMongoStatus withEntries(List entries) {
		this.migrationsApplied = entries;
		return this;
	}

	public enum MigrationStatus {
		OK, LOCK_NOT_ACQUIRED, ERROR, IN_PROGRESS;
	}

	@Override
	public String toString() {
		return "[status=" + status + ", message=" + message + ", migrationsApplied=" + migrationsApplied + "]";
	}

	public static MigraMongoStatus lockNotAcquired() {
		return new MigraMongoStatus(MigrationStatus.LOCK_NOT_ACQUIRED, "Couldn't obtain lock - doing nothing");
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy