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

liquibase.logging.mdc.customobjects.ChangesetsRolledback Maven / Gradle / Ivy

The newest version!
package liquibase.logging.mdc.customobjects;

import liquibase.logging.mdc.CustomMdcObject;
import lombok.Getter;
import lombok.Setter;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@Getter
@Setter
public class ChangesetsRolledback implements CustomMdcObject {

    private int changesetCount;
    private List changesets;

    /**
     * Constructor for service locator.
     */
    public ChangesetsRolledback() {
    }

    public ChangesetsRolledback(List changeSets) {
        changesetCount = changeSets.size();
        this.changesets = changeSets;
    }

    /**
     * Generate a {@link ChangesetsRolledback} object from a list of {@link liquibase.changelog.ChangeSet}s.
     */
    public static ChangesetsRolledback fromChangesetList(List changeSets) {
        if (changeSets != null) {
            List changesets = changeSets.stream().map(ChangeSet::fromChangeSet).collect(Collectors.toList());
            return new ChangesetsRolledback(changesets);
        } else {
            return new ChangesetsRolledback(Collections.emptyList());
        }
    }

    @Getter
    @Setter
    public static class ChangeSet {

        private String changesetId;
        private String author;
        private String filepath;
        private String deploymentId;

        public ChangeSet(String changesetId, String author, String filepath, String deploymentId) {
            this.changesetId = changesetId;
            this.author = author;
            this.filepath = filepath;
            this.deploymentId = deploymentId;
        }

        public static ChangeSet fromChangeSet(liquibase.changelog.ChangeSet changeSet) {
            return new ChangeSet(changeSet.getId(), changeSet.getAuthor(), changeSet.getFilePath(), changeSet.getDeploymentId());
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy