package dev.dinauer.maven.maven.core.context;

import dev.dinauer.maven.maven.shared.Extensions;
import org.apache.commons.lang3.Strings;

public class VersionContext extends ArtifactContext
{
    private static final String SNAPSHOT_SUFFIX = "-SNAPSHOT";

    private final String version;

    public VersionContext(Extensions extensions, String groupId, String artifactId, String filename, String version)
    {
        super(extensions, groupId, artifactId, filename);
        this.version = version;
    }

    public String version()
    {
        return version;
    }

    public boolean isSnapshot()
    {
        return Strings.CI.endsWith(version, SNAPSHOT_SUFFIX);
    }

    public String plainVersion()
    {
        return Strings.CI.removeEnd(version, SNAPSHOT_SUFFIX);
    }
}
