Add default for EnginePlugin.getEngineFactory (#2419)
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 <jmazane@amazon.com>
This commit is contained in:
parent
02ffd4c548
commit
f52f6f5052
|
@ -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:
|
||||
|
|
|
@ -146,6 +146,21 @@ public class EngineConfigFactoryTests extends OpenSearchTestCase {
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue