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

lphystudio.app.manager.Dependency Maven / Gradle / Ivy

The newest version!
package lphystudio.app.manager;

import java.util.Objects;

/**
 * Data class maps to pom.xml {@code }.
 * @author Walter Xie
 */
public class Dependency implements Comparable {

    private String groupId;
    private String artifactId;
    private String version;
//    private String scope;

    public Dependency(String groupId, String artifactId, String version) { //, String scope
        this.groupId = Objects.requireNonNull(groupId);
        this.artifactId = Objects.requireNonNull(artifactId);
        this.version = Objects.requireNonNull(version);
//        this.scope = scope;
    }

    public Dependency() { }

    public void setGroupId(String groupId) {
        this.groupId = Objects.requireNonNull(groupId);
    }

    public void setArtifactId(String artifactId) {
        this.artifactId = Objects.requireNonNull(artifactId);
    }

    public void setVersion(String version) {
        this.version = Objects.requireNonNull(version);
    }

    public String getGroupId() {
        return groupId;
    }

    public String getArtifactId() {
        return artifactId;
    }

    public String getVersion() {
        return version;
    }

    @Override
    public String toString() {
        return groupId + ':' + artifactId + ':' + version;
    }

    @Override
    public int compareTo(Dependency other) {
        // Handle null cases to avoid NullPointerException
        if (other == null) {
            return 1; // Consider non-null greater than null
        }

        // Concatenate the fields for comparison
        String thisKey = getDependencyId().toLowerCase();
        String otherKey = other.getDependencyId().toLowerCase();

        // Compare the concatenated strings
        return thisKey.compareTo(otherKey);
    }

    public String getDependencyId() {
        return groupId + artifactId + version;
    }


    //    public String getScope() {
//        return scope;
//    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy