Package org.mongeez.validation

Source Code of org.mongeez.validation.DefaultChangeSetsValidator

package org.mongeez.validation;

import java.util.List;

import org.mongeez.commands.ChangeSet;

public class DefaultChangeSetsValidator implements ChangeSetsValidator {

    @Override
    public void validate(List<ChangeSet> changesets) throws ValidationException {
        changeSetIdsNotUnique(changesets);
    }

    private void changeSetIdsNotUnique(List<ChangeSet> changeSets) {
        for (int i = 0; i < changeSets.size() / 2; i++) {
            ChangeSet changeSetI = changeSets.get(i);
            String changeSetIId = changeSetI.getChangeId();

            for (int j = i + 1; j < changeSets.size(); j++) {
                ChangeSet changeSetJ = changeSets.get(j);
                String changeSetJId = changeSetJ.getChangeId();

                if (changeSetIId.equals(changeSetJId)) {
                    throw new ValidationException("ChangeSetId " + changeSetIId + " is not unique.");
                }
            }
        }
    }
}
TOP

Related Classes of org.mongeez.validation.DefaultChangeSetsValidator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.