refactor(es): improve readability of getOrDefault config checks
Fixes
MODIFY
common/es/src/main/java/io/apiman/common/es/util/AbstractEsComponent.java
common/es/src/main/java/io/apiman/common/es/util/AbstractEsComponent.java
@@ -38,10 +38,7 @@ public abstract class AbstractEsComponent {
*/
public AbstractEsComponent(Map<String, String> config) {
this.config = config;
- String indexPrefix = config.get("client.indexPrefix"); //$NON-NLS-1$
- if (indexPrefix == null) {
- indexPrefix = getDefaultIndexPrefix();
- }
+ String indexPrefix = config.getOrDefault("client.indexPrefix", getDefaultIndexPrefix()); //$NON-NLS-1$
this.indexPrefix = indexPrefix;
}

MODIFY
common/es/src/main/java/io/apiman/common/es/util/DefaultEsClientFactory.java
common/es/src/main/java/io/apiman/common/es/util/DefaultEsClientFactory.java
@@ -78,10 +78,7 @@ public class DefaultEsClientFactory extends AbstractClientFactory implements IEs
String defaultIndexPrefix) {
RestHighLevelClient client;
- String indexNamePrefix = config.get("client.indexPrefix"); //$NON-NLS-1$
- if (indexNamePrefix == null) {
- indexNamePrefix = defaultIndexPrefix;
- }
+ String indexNamePrefix = config.getOrDefault("client.indexPrefix", defaultIndexPrefix); //$NON-NLS-1$
client = this.createEsClient(config, esIndices, indexNamePrefix);
return client;
}

MODIFY
common/es/src/main/java/io/apiman/common/es/util/LocalClientFactory.java
common/es/src/main/java/io/apiman/common/es/util/LocalClientFactory.java
@@ -42,10 +42,7 @@ public class LocalClientFactory extends AbstractClientFactory implements IEsClie
@Override
public RestHighLevelClient createClient(Map<String, String> config, Map<String, EsIndexProperties> esIndices, String defaultIndexPrefix) {
RestHighLevelClient client;
- String indexName = config.get("client.indexPrefix"); //$NON-NLS-1$
- if (indexName == null) {
- indexName = defaultIndexPrefix;
- }
+ String indexName = config.getOrDefault("client.indexPrefix", defaultIndexPrefix); //$NON-NLS-1$
client = createLocalClient(config, indexName, esIndices);
return client;
}

refactor(es): improve readability of getOrDefault config checks

Fixes #1025