Slight refactoring of dependency/Dependency.java class

* Re-uses constructors to reduce duplicate code
* Makes sure the constructor with relocate-argument actually sets `this.relocate`
* Use `this.` for accessing class variables
This commit is contained in:
Christian Koop 2024-01-13 18:41:18 +01:00
parent 21bf900448
commit adcf8619ec
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3

View File

@ -2,30 +2,21 @@ package com.craftaro.core.dependency;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class Dependency {
private final String repositoryUrl;
private final String groupId;
private final String artifactId;
private final String version;
private boolean relocate;
private Relocation relocation;
private final Relocation relocation;
public Dependency(String repositoryUrl, String groupId, String artifactId, String version) {
this.repositoryUrl = repositoryUrl;
this.groupId = groupId.replaceAll(";", ".");
this.artifactId = artifactId;
this.version = version;
this.relocate = true;
this(repositoryUrl, groupId, artifactId, version, true);
}
public Dependency(String repositoryUrl, String groupId, String artifactId, String version, boolean relocate) {
this.repositoryUrl = repositoryUrl;
this.groupId = groupId.replaceAll(";", ".");
this.artifactId = artifactId;
this.version = version;
this(repositoryUrl, groupId, artifactId, version, null);
this.relocate = relocate;
}
public Dependency(String repositoryUrl, String groupId, String artifactId, String version, @Nullable Relocation relocation) {
@ -38,26 +29,26 @@ public class Dependency {
}
public String getRepositoryUrl() {
return repositoryUrl;
return this.repositoryUrl;
}
public String getGroupId() {
return groupId;
return this.groupId;
}
public String getArtifactId() {
return artifactId;
return this.artifactId;
}
public String getVersion() {
return version;
return this.version;
}
public Relocation getRelocation() {
return relocation;
return this.relocation;
}
public boolean relocate() {
return relocate;
return this.relocate;
}
}