Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@ protected AbstractHeapBasedIndex() {
public void index(final Object object) {
final var objectClass = object.getClass();

// index the object itself if it is annotated with @Indexable
if (Introspection.hasDeclaredAnnotation(objectClass, Indexable.class)) {
this.objectByClass.compute(objectClass, (_, existing) -> {
final var objects = existing == null
? ConcurrentHashMap.newKeySet()
: existing;
// always register the object in objectByClass — an @Indexable function field is sufficient
// to make the type a class-membership participant; type-level @Indexable remains accepted
// but is no longer required
this.objectByClass.compute(objectClass, (_, existing) -> {
final var objects = existing == null
? ConcurrentHashMap.newKeySet()
: existing;

objects.add(object);
return objects;
});
}
objects.add(object);
return objects;
});

// index the values produced by public static final @Indexable Function fields
this.indexableFunctionFieldsByClass
Expand Down Expand Up @@ -235,19 +235,17 @@ public void index(final Object object) {
public void unindex(final Object object) {
final var objectClass = object.getClass();

// unindex the object itself if it is annotated with @Indexable
if (Introspection.hasDeclaredAnnotation(objectClass, Indexable.class)) {
this.objectByClass.compute(objectClass, (_, existing) -> {
if (existing == null) {
return null; // nothing to remove
} else {
existing.remove(object);
return existing.isEmpty()
? null
: existing; // return null if empty
}
});
}
// always remove from objectByClass, symmetrical with index()
this.objectByClass.compute(objectClass, (_, existing) -> {
if (existing == null) {
return null;
} else {
existing.remove(object);
return existing.isEmpty()
? null
: existing;
}
});

// unindex the values produced by public static final @Indexable Function fields
this.indexableFunctionFieldsByClass
Expand Down
Loading