Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions core/src/main/java/net/byteflux/libby/relocation/Relocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public class Relocation {
* @param excludes classes and resources to exclude
*/
public Relocation(String pattern, String relocatedPattern, Collection<String> includes, Collection<String> excludes) {
this.pattern = requireNonNull(pattern, "pattern").replace("{}", ".");
this.relocatedPattern = requireNonNull(relocatedPattern, "relocatedPattern").replace("{}", ".");
this.includes = includes != null ? Collections.unmodifiableList(new LinkedList<>(includes)) : Collections.emptyList();
this.excludes = excludes != null ? Collections.unmodifiableList(new LinkedList<>(excludes)) : Collections.emptyList();
this.pattern = normalizePattern(requireNonNull(pattern, "pattern"));
this.relocatedPattern = normalizePattern(requireNonNull(relocatedPattern, "relocatedPattern"));
this.includes = normalizePatternCollection(includes);
this.excludes = normalizePatternCollection(excludes);
}

/**
Expand Down Expand Up @@ -93,6 +93,17 @@ public Collection<String> getExcludes() {
return excludes;
}

private String normalizePattern(String pattern) {
return pattern.replace("{}", ".");
}

private Collection<String> normalizePatternCollection(Collection<String> patterns) {
if (patterns == null) {
return Collections.emptyList();
}
return patterns.stream().map(this::normalizePattern).toList();
}

/**
* Creates a new relocation builder.
*
Expand Down