[Minor] Code cleanup
This commit is contained in:
parent
7ffaab1bb8
commit
672da1b132
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
package li.strolch.agent.impl;
|
||||
|
||||
import static java.util.function.Function.identity;
|
||||
import static li.strolch.model.StrolchModelConstants.TEMPLATE;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
@ -44,7 +43,7 @@ public abstract class TransientElementMap<T extends StrolchRootElement> implemen
|
|||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(TransientElementMap.class);
|
||||
|
||||
private Map<String, Map<String, T>> elementMap;
|
||||
private final Map<String, Map<String, T>> elementMap;
|
||||
|
||||
public TransientElementMap() {
|
||||
this.elementMap = new HashMap<>();
|
||||
|
@ -63,8 +62,8 @@ public abstract class TransientElementMap<T extends StrolchRootElement> implemen
|
|||
|
||||
@Override
|
||||
public synchronized long querySize(StrolchTransaction tx) {
|
||||
return this.elementMap.entrySet().stream() //
|
||||
.map(e -> e.getValue().entrySet().size()) //
|
||||
return this.elementMap.values().stream() //
|
||||
.map(map -> map.entrySet().size()) //
|
||||
.mapToInt(Integer::valueOf) //
|
||||
.sum();
|
||||
}
|
||||
|
@ -227,10 +226,8 @@ public abstract class TransientElementMap<T extends StrolchRootElement> implemen
|
|||
|
||||
@Override
|
||||
public synchronized Set<String> getAllKeys(StrolchTransaction tx) {
|
||||
return this.elementMap.entrySet().stream() //
|
||||
.map(e -> e.getValue().entrySet().stream() //
|
||||
.map(Map.Entry::getKey)) //
|
||||
.flatMap(identity()) //
|
||||
return this.elementMap.values().stream() //
|
||||
.flatMap(map -> map.keySet().stream()) //
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
@ -240,9 +237,7 @@ public abstract class TransientElementMap<T extends StrolchRootElement> implemen
|
|||
if (byType == null)
|
||||
return new HashSet<>(0);
|
||||
|
||||
return byType.entrySet().stream() //
|
||||
.map(Map.Entry::getKey) //
|
||||
.collect(Collectors.toSet());
|
||||
return new HashSet<>(byType.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1375,11 +1375,11 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
|||
changedR = this.objectFilter.getAdded(Resource.class, Tags.RESOURCE);
|
||||
if (changedR.size() == 1) {
|
||||
AddResourceCommand cmd = new AddResourceCommand(this);
|
||||
cmd.setResource((Resource) changedR.get(0));
|
||||
cmd.setResource(changedR.get(0));
|
||||
addCommand(cmd);
|
||||
} else if (changedR.size() > 1) {
|
||||
AddResourcesCommand cmd = new AddResourcesCommand(this);
|
||||
changedR.stream().map(e -> (Resource) e).forEach(cmd::addResource);
|
||||
cmd.setResources(changedR);
|
||||
addCommand(cmd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue