Skip to content

Commit

Permalink
Add toString #2515 (#2516)
Browse files Browse the repository at this point in the history
Signed-off-by: Arjan Tijms <[email protected]>
  • Loading branch information
arjantijms authored Mar 11, 2022
1 parent 73f2c7c commit a89dedb
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
*/
package cloud.piranha.resource.impl;

import cloud.piranha.resource.api.Resource;

import java.io.InputStream;
import java.net.URL;
import java.util.stream.Stream;

import cloud.piranha.resource.api.Resource;

/**
* A {@link Resource} wrapper with a custom name
*/
Expand Down Expand Up @@ -78,4 +78,9 @@ public String getName() {
return resourceName;
}

@Override
public String toString() {
return getName() + " " + super.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
*/
package cloud.piranha.resource.impl;

import cloud.piranha.resource.api.Resource;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.stream.Stream;

import cloud.piranha.resource.api.Resource;

/**
* The byte-array resource.
*
Expand Down Expand Up @@ -163,4 +164,14 @@ private String getLocationFromUrl(String url) {

}

@Override
public String getName() {
return location;
}

@Override
public String toString() {
return getName() + " " + super.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
*/
package cloud.piranha.resource.impl;

import cloud.piranha.resource.api.Resource;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.stream.Stream;

import cloud.piranha.resource.api.Resource;

/**
* A resource backed by a class.
*
Expand Down Expand Up @@ -84,4 +85,14 @@ public Stream<String> getAllLocations() {
}
return result.stream();
}

@Override
public String getName() {
return location;
}

@Override
public String toString() {
return getName() + " " + super.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
Expand Down Expand Up @@ -59,7 +59,7 @@ public class DirectoryResource implements Resource {
*/
public DirectoryResource() {
}

/**
* Constructor.
*
Expand Down Expand Up @@ -115,7 +115,7 @@ public InputStream getResourceAsStream(String location) {

return result;
}

@Override
public Stream<String> getAllLocations() {
try {
Expand Down Expand Up @@ -152,4 +152,9 @@ public String getName() {
return rootDirectory.getName();
}

@Override
public String toString() {
return getName() + " " + super.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
package cloud.piranha.resource.impl;

import cloud.piranha.resource.api.Resource;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand All @@ -41,6 +40,8 @@
import java.util.stream.Stream;
import java.util.zip.ZipEntry;

import cloud.piranha.resource.api.Resource;

/**
* The default JarResource.
*
Expand Down Expand Up @@ -155,4 +156,9 @@ public void setJarFile(File jarFile) {
public String getName() {
return jarFile.getName();
}

@Override
public String toString() {
return getName() + " " + super.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
*/
package cloud.piranha.resource.impl;

import cloud.piranha.resource.api.Resource;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
Expand All @@ -38,6 +36,8 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;

import cloud.piranha.resource.api.Resource;

/**
* A resource wrapper that loads the versioned entries from META-INF/versions if
* the resource contains a main attribute named "Multi-Release" in the META-INF/MANIFEST.MF
Expand Down Expand Up @@ -148,4 +148,9 @@ public Stream<String> getAllLocations() {
public String getName() {
return resource.getName();
}

@Override
public String toString() {
return getName() + " " + super.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
package cloud.piranha.resource.impl;

import cloud.piranha.resource.api.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
Expand All @@ -36,6 +35,8 @@
import java.util.jar.JarFile;
import java.util.stream.Stream;

import cloud.piranha.resource.api.Resource;

/**
* The default PrefixJarResource.
*
Expand Down Expand Up @@ -113,7 +114,7 @@ public InputStream getResourceAsStream(String location) {
}
return result;
}

@Override
public Stream<String> getAllLocations() {
return Stream.empty();
Expand Down Expand Up @@ -159,4 +160,9 @@ public String getName() {
return jarFile.getName();
}

@Override
public String toString() {
return getName() + " " + super.toString();
}

}

0 comments on commit a89dedb

Please sign in to comment.