Skip to content

Commit

Permalink
Add default for EnginePlugin.getEngineFactory (#2419)
Browse files Browse the repository at this point in the history
Adds default implementation for getEngineFactory in EnginePlugin. The
default just returns Optional.empty(), allowing plugin developers to
implement this plugin without implementing this method.

Signed-off-by: John Mazanec <[email protected]>
  • Loading branch information
jmazanec15 authored Mar 16, 2022
1 parent 02ffd4c commit f52f6f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public interface EnginePlugin {
*
* @return an optional engine factory
*/
Optional<EngineFactory> getEngineFactory(IndexSettings indexSettings);
default Optional<EngineFactory> getEngineFactory(IndexSettings indexSettings) {
return Optional.empty();
}

/**
* EXPERT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ public void testCreateCodecServiceFromFactory() {
assertNotNull(config.getCodec());
}

public void testGetEngineFactory() {
final EngineFactory engineFactory = config -> null;
EnginePlugin enginePluginThatImplementsGetEngineFactory = new EnginePlugin() {
@Override
public Optional<EngineFactory> getEngineFactory(IndexSettings indexSettings) {
return Optional.of(engineFactory);
}
};
assertEquals(engineFactory, enginePluginThatImplementsGetEngineFactory.getEngineFactory(null).orElse(null));

EnginePlugin enginePluginThatDoesNotImplementsGetEngineFactory = new EnginePlugin() {
};
assertFalse(enginePluginThatDoesNotImplementsGetEngineFactory.getEngineFactory(null).isPresent());
}

private static class FooEnginePlugin extends Plugin implements EnginePlugin {
@Override
public Optional<EngineFactory> getEngineFactory(final IndexSettings indexSettings) {
Expand Down

0 comments on commit f52f6f5

Please sign in to comment.