Skip to content

Commit

Permalink
Add missing @OverRide annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Jul 13, 2024
1 parent 267e19a commit 601d8a5
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ private SimpleFilter(
}

/** {@inheritDoc} */
@Override
public boolean canFilter(File jar) {
return jars.contains(jar);
}

/** {@inheritDoc} */
@Override
public boolean isFiltered(String classFile) {
String path = normalizePath(classFile);

Expand Down Expand Up @@ -155,5 +157,6 @@ private Set<String> normalizePatterns(Set<String> patterns) {
}

/** {@inheritDoc} */
@Override
public void finished() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ private boolean isExcluded(String path) {
return false;
}

@Override
public boolean canRelocatePath(String path) {
if (rawString) {
return Pattern.compile(pathPattern).matcher(path).find();
Expand All @@ -192,10 +193,12 @@ public boolean canRelocatePath(String path) {
return isIncluded(path) && !isExcluded(path) && path.startsWith(pathPattern);
}

@Override
public boolean canRelocateClass(String clazz) {
return !rawString && clazz.indexOf('/') < 0 && canRelocatePath(clazz.replace('.', '/'));
}

@Override
public String relocatePath(String path) {
if (rawString) {
return path.replaceAll(pathPattern, shadedPathPattern);
Expand All @@ -204,10 +207,12 @@ public String relocatePath(String path) {
}
}

@Override
public String relocateClass(String clazz) {
return rawString ? clazz : clazz.replaceFirst(pattern, shadedPattern);
}

@Override
public String applyToSourceContent(String sourceContent) {
if (rawString) {
return sourceContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* An abstract class to implement once the old non-reproducible ResourceTransformer API.
*/
abstract class AbstractCompatibilityTransformer implements ReproducibleResourceTransformer {
@Override
public final void processResource(String resource, InputStream is, List<Relocator> relocators) throws IOException {
processResource(resource, is, relocators, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ public class ApacheNoticeResourceTransformer extends AbstractCompatibilityTransf

private static final String NOTICE_MD_PATH = "META-INF/NOTICE.md";

@Override
public boolean canTransformResource(String resource) {
return NOTICE_PATH.equalsIgnoreCase(resource)
|| NOTICE_TXT_PATH.equalsIgnoreCase(resource)
|| NOTICE_MD_PATH.equalsIgnoreCase(resource);
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
if (entries.isEmpty()) {
Expand Down Expand Up @@ -167,10 +169,12 @@ public void processResource(String resource, InputStream is, List<Relocator> rel
}
}

@Override
public boolean hasTransformedResource() {
return true;
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
JarEntry jarEntry = new JarEntry(NOTICE_PATH);
jarEntry.setTime(time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ public class AppendingTransformer extends AbstractCompatibilityTransformer {

private long time = Long.MIN_VALUE;

@Override
public boolean canTransformResource(String r) {
return resource != null && resource.equalsIgnoreCase(r);
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
IOUtil.copy(is, data);
Expand All @@ -51,10 +53,12 @@ public void processResource(String resource, InputStream is, List<Relocator> rel
}
}

@Override
public boolean hasTransformedResource() {
return data.size() > 0;
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
JarEntry jarEntry = new JarEntry(resource);
jarEntry.setTime(time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class DontIncludeResourceTransformer extends AbstractCompatibilityTransfo

List<String> resources;

@Override
public boolean canTransformResource(String r) {
if ((resource != null && !resource.isEmpty()) && r.endsWith(resource)) {
return true;
Expand All @@ -50,15 +51,18 @@ public boolean canTransformResource(String r) {
return false;
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
// no op
}

@Override
public boolean hasTransformedResource() {
return false;
}

@Override
public void modifyOutputStream(JarOutputStream os) throws IOException {
// no op
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,25 @@ public class IncludeResourceTransformer extends AbstractCompatibilityTransformer

private long time = Long.MIN_VALUE;

@Override
public boolean canTransformResource(String r) {
return false;
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
if (time > this.time) {
this.time = time;
}
}

@Override
public boolean hasTransformedResource() {
return file != null && file.exists();
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
JarEntry jarEntry = new JarEntry(resource);
jarEntry.setTime(time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ public void setBasename(String basename) {
resourceBundlePattern = Pattern.compile(basename + "(_[a-zA-Z]+){0,3}\\.properties");
}

@Override
public boolean canTransformResource(String r) {
return resourceBundlePattern != null && resourceBundlePattern.matcher(r).matches();
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
ByteArrayOutputStream data = dataMap.get(resource);
Expand All @@ -72,10 +74,12 @@ public void processResource(String resource, InputStream is, List<Relocator> rel
}
}

@Override
public boolean hasTransformedResource() {
return !dataMap.isEmpty();
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
for (Map.Entry<String, ByteArrayOutputStream> dataEntry : dataMap.entrySet()) {
JarEntry jarEntry = new JarEntry(dataEntry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ public class ServicesResourceTransformer extends AbstractCompatibilityTransforme

private long time = Long.MIN_VALUE;

@Override
public boolean canTransformResource(String resource) {
return resource.startsWith(SERVICES_PATH);
}

@Override
public void processResource(String resource, InputStream is, final List<Relocator> relocators, long time)
throws IOException {
resource = resource.substring(SERVICES_PATH.length() + 1);
Expand Down Expand Up @@ -80,10 +82,12 @@ public void processResource(String resource, InputStream is, final List<Relocato
}
}

@Override
public boolean hasTransformedResource() {
return !serviceEntries.isEmpty();
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
for (Map.Entry<String, Set<String>> entry : serviceEntries.entrySet()) {
String key = entry.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ public class XmlAppendingTransformer extends AbstractCompatibilityTransformer {

private long time = Long.MIN_VALUE;

@Override
public boolean canTransformResource(String r) {
return resource != null && resource.equalsIgnoreCase(r);
}

@Override
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
Document r;
Expand All @@ -65,6 +67,7 @@ public void processResource(String resource, InputStream is, List<Relocator> rel
builder.setExpandEntities(false);
if (ignoreDtd) {
builder.setEntityResolver(new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
return new InputSource(new StringReader(""));
Expand Down Expand Up @@ -105,10 +108,12 @@ public InputSource resolveEntity(String publicId, String systemId)
}
}

@Override
public boolean hasTransformedResource() {
return doc != null;
}

@Override
public void modifyOutputStream(JarOutputStream jos) throws IOException {
JarEntry jarEntry = new JarEntry(resource);
jarEntry.setTime(time);
Expand Down

0 comments on commit 601d8a5

Please sign in to comment.