Skip to content

Commit

Permalink
Replace List to Set in FileResourceHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Apr 12, 2024
1 parent d566d85 commit e6fa958
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* Class that handles resource closing.
Expand All @@ -32,10 +33,10 @@
*/
public class FileResourceHandler implements Closeable {

private final List<Closeable> resources;
private final Set<Closeable> resources;

public FileResourceHandler() {
this.resources = new ArrayList<>();
this.resources = new HashSet<>();
}

/**
Expand All @@ -46,7 +47,7 @@ public FileResourceHandler() {
public void addResource(ASFileStreamCloser obj) {
if (obj != null) {
Closeable resource = obj.getStream();
if (resource != null && !resources.contains(resource)) {
if (resource != null) {
resources.add(obj);
}
}
Expand All @@ -58,7 +59,7 @@ public void addResource(ASFileStreamCloser obj) {
* @param res is a closeable object to be stored.
*/
public void addResource(Closeable res) {
if (res != null && !resources.contains(res)) {
if (res != null) {
resources.add(res);
}
}
Expand Down

0 comments on commit e6fa958

Please sign in to comment.