Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-turner committed Jul 11, 2023
1 parent 406552e commit fa89804
Showing 1 changed file with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@
public class ConfigurationImpl implements Configuration {

private final AccumuloConfiguration acfg;
private Map<String,String> customProps;
private Map<String,String> tableCustomProps;
private final AccumuloConfiguration.Deriver<Map<String, String>> tableCusomerDeriver;
private final AccumuloConfiguration.Deriver<Map<String, String>> customDeriver;


public ConfigurationImpl(AccumuloConfiguration acfg) {
this.acfg = acfg;
this.customDeriver = acfg.newDeriver(aconf-> buildCustom(aconf, Property.GENERAL_ARBITRARY_PROP_PREFIX));
this.tableCusomerDeriver = acfg.newDeriver(aconf-> buildCustom(aconf, Property.TABLE_ARBITRARY_PROP_PREFIX));
}

@Override
Expand Down Expand Up @@ -83,11 +86,7 @@ public Map<String,String> getWithPrefix(String prefix) {

@Override
public Map<String,String> getCustom() {
if (customProps == null) {
customProps = buildCustom(Property.GENERAL_ARBITRARY_PROP_PREFIX);
}

return customProps;
return customDeriver.derive();
}

@Override
Expand All @@ -97,20 +96,16 @@ public String getCustom(String keySuffix) {

@Override
public Map<String,String> getTableCustom() {
if (tableCustomProps == null) {
tableCustomProps = buildCustom(Property.TABLE_ARBITRARY_PROP_PREFIX);
}

return tableCustomProps;
return tableCusomerDeriver.derive();
}

@Override
public String getTableCustom(String keySuffix) {
return getTableCustom().get(keySuffix);
}

private Map<String,String> buildCustom(Property customPrefix) {
return acfg.getAllPropertiesWithPrefix(customPrefix).entrySet().stream().collect(
private static Map<String,String> buildCustom(AccumuloConfiguration conf, Property customPrefix) {
return conf.getAllPropertiesWithPrefix(customPrefix).entrySet().stream().collect(
Collectors.toUnmodifiableMap(e -> e.getKey().substring(customPrefix.getKey().length()),
Entry::getValue));
}
Expand Down

0 comments on commit fa89804

Please sign in to comment.