Skip to content

Commit a2c0350

Browse files
committed
fix: avoid adding blank strings as hasPart IDs to DataSetEntitys
1 parent c07728d commit a2c0350

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/edu/kit/datamanager/ro_crate/entities/data/DataSetEntity.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import java.util.HashSet;
1111
import java.util.Set;
12+
import java.util.stream.Collectors;
1213

1314
/**
1415
* A helping class for the creating of Data entities of type Dataset.
@@ -35,7 +36,9 @@ public class DataSetEntity extends DataEntity {
3536
*/
3637
public DataSetEntity(AbstractDataSetBuilder<?> entityBuilder) {
3738
super(entityBuilder);
38-
this.hasPart = entityBuilder.hasPart;
39+
this.hasPart = entityBuilder.hasPart.stream()
40+
.filter(s -> !s.isBlank())
41+
.collect(Collectors.toSet());
3942
this.addType(TYPE);
4043
}
4144

@@ -44,7 +47,9 @@ public void removeFromHasPart(String str) {
4447
}
4548

4649
public void addToHasPart(String id) {
47-
this.hasPart.add(id);
50+
if (id != null && !id.isEmpty()) {
51+
this.hasPart.add(id);
52+
}
4853
}
4954

5055
/**

0 commit comments

Comments
 (0)