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

io.bdeploy.bhive.op.ManifestNextIdOperation Maven / Gradle / Ivy

Go to download

Public API including dependencies, ready to be used for integrations and plugins.

There is a newer version: 7.3.6
Show newest version
package io.bdeploy.bhive.op;

import java.util.Optional;

import io.bdeploy.bhive.BHive;
import io.bdeploy.bhive.ReadOnlyOperation;
import io.bdeploy.common.util.RuntimeAssert;

/**
 * Returns the next available version number for Manifests which use a simple counter versioning scheme.
 */
@ReadOnlyOperation
public class ManifestNextIdOperation extends BHive.Operation {

    private String key;

    @Override
    public Long call() throws Exception {
        RuntimeAssert.assertNotNull(key, "No Manifest to inspect");

        Optional max = execute(new ManifestMaxIdOperation().setManifestName(key));
        return max.orElse(0L) + 1;
    }

    /**
     * @param name the name of the manifest to calculate a new version for. Note that this must be the full name of the
     *            manifest, not just a segment.
     * @return the operation for chaining.
     */
    public ManifestNextIdOperation setManifestName(String name) {
        this.key = name;
        return this;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy