Skip to content

Commit

Permalink
Replace inner interface in ComponentMatcher with Function
Browse files Browse the repository at this point in the history
Signed-off-by: Gyúróczki Gergő <gergonoorbi@gmail.com>
  • Loading branch information
Degubi committed Oct 9, 2019
1 parent 5f869a7 commit 6ec44ba
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/main/java/org/eclipse/yasson/internal/ComponentMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;

/**
* Searches for a registered components or Serializer for a given type.
Expand All @@ -46,15 +47,6 @@ public class ComponentMatcher {
*/
private volatile boolean genericComponents;

/**
* Supplier for component binging.
* @param <T> component binding class
*/
private interface ComponentSupplier<T extends AbstractComponentBinding> {

T getComponent(ComponentBindings componentBindings);
}

private final ConcurrentMap<Type, ComponentBindings> userComponents;

/**
Expand Down Expand Up @@ -186,9 +178,9 @@ public Optional<AdapterBinding> getDeserializeAdapterBinding(Type propertyRuntim
return Optional.of(customization.getDeserializeAdapterBinding());
}

private <T extends AbstractComponentBinding> Optional<T> searchComponentBinding(Type runtimeType, ComponentSupplier<T> supplier) {
private <T extends AbstractComponentBinding> Optional<T> searchComponentBinding(Type runtimeType, Function<ComponentBindings, T> supplier) {
for (ComponentBindings componentBindings : userComponents.values()) {
final T component = supplier.getComponent(componentBindings);
final T component = supplier.apply(componentBindings);
if (component != null && matches(runtimeType, componentBindings.getBindingType())) {
return Optional.of(component);
}
Expand Down

0 comments on commit 6ec44ba

Please sign in to comment.