Skip to content

Commit

Permalink
handle null return from func.apply
Browse files Browse the repository at this point in the history
  • Loading branch information
firestar committed Dec 28, 2023
1 parent 9f8c2d7 commit e53e829
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = 'com.nucleodb'
version = '1.13.21'
version = '1.13.22'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.collect.Queues;
import com.google.common.collect.Sets;
import com.nucleodb.library.database.modifications.ConnectionCreate;
import com.nucleodb.library.database.modifications.ConnectionDelete;
import com.nucleodb.library.database.modifications.ConnectionUpdate;
Expand Down Expand Up @@ -281,22 +282,31 @@ public Set<DataEntry> handleIndexOperation(Object obj, DataEntryProjection dataE
if (dataEntryProjection == null) {
dataEntryProjection = new DataEntryProjection();
}
Stream<DataEntry> process = dataEntryProjection.process(func.apply(obj).stream());
if (dataEntryProjection.isWritable()) {
return process.map(de -> (DataEntry) de.copy(this.getConfig().getDataEntryClass())).collect(Collectors.toSet());
Set<DataEntry> apply = func.apply(obj);
if(apply!=null) {
Stream<DataEntry> process = dataEntryProjection.process(apply.stream());

if (dataEntryProjection.isWritable()) {
return process.map(de -> (DataEntry) de.copy(this.getConfig().getDataEntryClass())).collect(Collectors.toSet());
}
return process.collect(Collectors.toSet());
}
return process.collect(Collectors.toSet());
return Sets.newTreeSet();
}

public Set<DataEntry> handleIndexStringOperation(String obj, DataEntryProjection dataEntryProjection, Function<String, Set<DataEntry>> func) {
if (dataEntryProjection == null) {
dataEntryProjection = new DataEntryProjection();
}
Stream<DataEntry> process = dataEntryProjection.process(func.apply(obj).stream());
if (dataEntryProjection.isWritable()) {
return process.map(de -> (DataEntry) de.copy(this.getConfig().getDataEntryClass())).collect(Collectors.toSet());
Set<DataEntry> apply = func.apply(obj);
if(apply!=null) {
Stream<DataEntry> process = dataEntryProjection.process(apply.stream());
if (dataEntryProjection.isWritable()) {
return process.map(de -> (DataEntry) de.copy(this.getConfig().getDataEntryClass())).collect(Collectors.toSet());
}
return process.collect(Collectors.toSet());
}
return process.collect(Collectors.toSet());
return Sets.newTreeSet();
}

public Set<DataEntry> search(String key, Object searchObject, DataEntryProjection dataEntryProjection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.nucleodb.library.database.modifications.Create;
import com.nucleodb.library.database.tables.table.DataEntry;

import java.util.UUID;

public class AuthorDE extends DataEntry<Author>{
public AuthorDE(Author obj) {
super(obj);
Expand Down

0 comments on commit e53e829

Please sign in to comment.