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

com.anrisoftware.sscontrol.scripts.versionlimits.CheckVersionLimit Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2014-2015 Erwin Müller 
 *
 * This file is part of sscontrol-scripts-unix.
 *
 * sscontrol-scripts-unix is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * sscontrol-scripts-unix is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with sscontrol-scripts-unix. If not, see .
 */
package com.anrisoftware.sscontrol.scripts.versionlimits;

import javax.inject.Inject;

import com.anrisoftware.globalpom.version.Version;
import com.google.inject.assistedinject.Assisted;

/**
 * Checks the current version and the archive version.
 *
 * @author Erwin Mueller, [email protected]
 * @since 1.0
 */
public class CheckVersionLimit {

    private final Version currentVersion;

    private final Version archiveVersion;

    private final Version versionLimit;

    /**
     * @see CheckVersionLimitFactory#create(Version, Version, Version)
     */
    @Inject
    CheckVersionLimit(@Assisted("currentVersion") Version currentVersion,
            @Assisted("archiveVersion") Version archiveVersion,
            @Assisted("versionLimit") Version versionLimit) {
        this.currentVersion = currentVersion;
        this.archiveVersion = archiveVersion;
        this.versionLimit = versionLimit;
    }

    /**
     * Checks that the current service version is smaller then the archive
     * version, and that the archive version is in bounds the version limit.
     *
     * @return {@code true} if all of those conditions are true.
     */
    public boolean checkVersion() {
        boolean different = currentVersion.compareTo(archiveVersion) <= 0;
        boolean bounds = archiveVersion.compareTo(versionLimit) <= 0;
        return different && bounds;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy