Refactor Dependency class a bit

This commit is contained in:
Luck 2019-03-03 16:46:20 +00:00
parent 2cf919a17a
commit 512b621a7a
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 13 additions and 33 deletions

View File

@ -109,10 +109,8 @@ public enum Dependency {
"okhttp", "okhttp",
"3.12.1", "3.12.1",
"B8PYLKfq9HIvALLagH3Hhg9haa5gz+3PXUAhj5CICkY=", "B8PYLKfq9HIvALLagH3Hhg9haa5gz+3PXUAhj5CICkY=",
Relocation.allOf( Relocation.of(RelocationHelper.OKHTTP3_STRING, RelocationHelper.OKHTTP3_STRING),
Relocation.of(RelocationHelper.OKHTTP3_STRING, RelocationHelper.OKHTTP3_STRING), Relocation.of(RelocationHelper.OKIO_STRING, RelocationHelper.OKIO_STRING)
Relocation.of(RelocationHelper.OKIO_STRING, RelocationHelper.OKIO_STRING)
)
), ),
COMMODORE( COMMODORE(
"me{}lucko", "me{}lucko",
@ -182,21 +180,17 @@ public enum Dependency {
"mongo-java-driver", "mongo-java-driver",
"3.9.1", "3.9.1",
"mxKxkvmYluxV+Hdn57uyt+MjjSQUsFjxFw9tjhx0bm4=", "mxKxkvmYluxV+Hdn57uyt+MjjSQUsFjxFw9tjhx0bm4=",
Relocation.allOf( Relocation.of("mongodb", "com{}mongodb"),
Relocation.of("mongodb", "com{}mongodb"), Relocation.of("bson", "org{}bson")
Relocation.of("bson", "org{}bson")
)
), ),
JEDIS( JEDIS(
"redis.clients", "redis.clients",
"jedis", "jedis",
"2.10.1", "2.10.1",
"Pp7msE2yJk5QRF9ASqM/6glX95xsnrwkm9BfN37vLI4=", "Pp7msE2yJk5QRF9ASqM/6glX95xsnrwkm9BfN37vLI4=",
Relocation.allOf( Relocation.of("jedis", "redis{}clients{}jedis"),
Relocation.of("jedis", "redis{}clients{}jedis"), Relocation.of("jedisutil", "redis{}clients{}util"),
Relocation.of("jedisutil", "redis{}clients{}util"), Relocation.of("commonspool2", "org{}apache{}commons{}pool2")
Relocation.of("commonspool2", "org{}apache{}commons{}pool2")
)
), ),
COMMONS_POOL_2( COMMONS_POOL_2(
"org.apache.commons", "org.apache.commons",
@ -238,10 +232,8 @@ public enum Dependency {
"configurate-hocon", "configurate-hocon",
"3.5", "3.5",
"sOym1KPmQylGSfk90ZFqobuvoZfEWb7XMmMBwbHuxFw=", "sOym1KPmQylGSfk90ZFqobuvoZfEWb7XMmMBwbHuxFw=",
Relocation.allOf( Relocation.of("configurate", "ninja{}leaping{}configurate"),
Relocation.of("configurate", "ninja{}leaping{}configurate"), Relocation.of("hocon", "com{}typesafe{}config")
Relocation.of("hocon", "com{}typesafe{}config")
)
), ),
HOCON_CONFIG( HOCON_CONFIG(
"com{}typesafe", "com{}typesafe",
@ -255,10 +247,8 @@ public enum Dependency {
"configurate-toml", "configurate-toml",
"3.5", "3.5",
"U8p0XSTaNT/uebvLpO/vb6AhVGQDYiZsauSGB9zolPU=", "U8p0XSTaNT/uebvLpO/vb6AhVGQDYiZsauSGB9zolPU=",
Relocation.allOf( Relocation.of("configurate", "ninja{}leaping{}configurate"),
Relocation.of("configurate", "ninja{}leaping{}configurate"), Relocation.of("toml4j", "com{}moandjiezana{}toml")
Relocation.of("toml4j", "com{}moandjiezana{}toml")
)
), ),
TOML4J( TOML4J(
"com{}moandjiezana{}toml", "com{}moandjiezana{}toml",
@ -278,14 +268,10 @@ public enum Dependency {
private static final String MAVEN_FORMAT = "%s/%s/%s/%s-%s.jar"; private static final String MAVEN_FORMAT = "%s/%s/%s/%s-%s.jar";
Dependency(String groupId, String artifactId, String version, String checksum) { Dependency(String groupId, String artifactId, String version, String checksum) {
this(groupId, artifactId, version, checksum, ImmutableList.of()); this(groupId, artifactId, version, checksum, new Relocation[0]);
} }
Dependency(String groupId, String artifactId, String version, String checksum, Relocation relocation) { Dependency(String groupId, String artifactId, String version, String checksum, Relocation... relocations) {
this(groupId, artifactId, version, checksum, ImmutableList.of(relocation));
}
Dependency(String groupId, String artifactId, String version, String checksum, List<Relocation> relocations) {
String path = String.format(MAVEN_FORMAT, String path = String.format(MAVEN_FORMAT,
rewriteEscaping(groupId).replace(".", "/"), rewriteEscaping(groupId).replace(".", "/"),
rewriteEscaping(artifactId), rewriteEscaping(artifactId),

View File

@ -25,8 +25,6 @@
package me.lucko.luckperms.common.dependencies.relocation; package me.lucko.luckperms.common.dependencies.relocation;
import java.util.Arrays;
import java.util.List;
import java.util.Objects; import java.util.Objects;
public final class Relocation { public final class Relocation {
@ -36,10 +34,6 @@ public final class Relocation {
return new Relocation(pattern.replace("{}", "."), RELOCATION_PREFIX + id); return new Relocation(pattern.replace("{}", "."), RELOCATION_PREFIX + id);
} }
public static List<Relocation> allOf(Relocation... relocations) {
return Arrays.asList(relocations);
}
private final String pattern; private final String pattern;
private final String relocatedPattern; private final String relocatedPattern;