Skip to content

Commit

Permalink
use private record instead of private inner class
Browse files Browse the repository at this point in the history
  • Loading branch information
wetret committed Dec 18, 2024
1 parent bd4edf1 commit 30dce85
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ public class ReadData extends AbstractServiceDelegate implements InitializingBea
{
private static final Logger logger = LoggerFactory.getLogger(ReadData.class);

private static class DataResource
private record DataResource(Resource resource, InputStream stream, String mimetype)
{
private final Resource resource;
private final InputStream stream;
private final String mimetype;

public static DataResource of(Resource resource)
{
return new DataResource(resource, null, null);
Expand All @@ -48,13 +44,6 @@ public static DataResource of(InputStream stream, String mimeType)
return new DataResource(null, stream, mimeType);
}

private DataResource(Resource resource, InputStream stream, String mimetype)
{
this.resource = resource;
this.stream = stream;
this.mimetype = mimetype;
}

public boolean hasResource()
{
return resource != null;
Expand Down Expand Up @@ -123,8 +112,10 @@ private Resource getResource(DataResource attachment) throws IOException
// TODO handle stream directly and do not parse to resource
if (attachment.hasInputStream())
return new Binary().setData(attachment.stream.readAllBytes()).setContentType(attachment.mimetype);

return attachment.resource;
else if (attachment.hasResource())
return attachment.resource;
else
throw new RuntimeException("Binary not available as resource or stream");
}

private String getProjectIdentifier(Task task)
Expand Down

0 comments on commit 30dce85

Please sign in to comment.