Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
CarstenHollmann committed Jan 18, 2022
1 parent 6b2762a commit 919f95f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toSet;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -67,10 +68,8 @@ public ObjectNode encode(Map<SettingDefinitionGroup, Set<SettingDefinition<?>>>
}

public ObjectNode encode(Set<SettingDefinition<?>> settings) {
return settings.stream().sorted()
.collect(nodeFactory::objectNode,
(j, def) -> j.set(def.getKey(), encode(def)),
ObjectNode::setAll);
return settings.stream().sorted().collect(nodeFactory::objectNode,
(j, def) -> j.set(def.getKey(), encode(def)), ObjectNode::setAll);
}

public ObjectNode encode(SettingDefinition<?> def) {
Expand Down Expand Up @@ -105,7 +104,6 @@ protected String getType(SettingDefinition<?> def) {
return def.getType().toString();
}


public JsonNode encodeDefaultValue(SettingDefinition<?> def) {
if (def == null) {
return nodeFactory.nullNode();
Expand Down Expand Up @@ -156,23 +154,24 @@ public JsonNode encodeValue(SettingType type, Object value) {

private void encodeValue(ObjectNode o, Entry<SettingDefinition<?>, SettingValue<?>> e) {
SettingDefinition<?> def = e.getKey();
Object value = Optional.ofNullable(e.getValue())
.map(v -> (Object) v.getValue())
.orElseGet(def::getDefaultValue);
Object value =
Optional.ofNullable(e.getValue()).map(v -> (Object) v.getValue()).orElseGet(def::getDefaultValue);
o.set(def.getKey(), encodeValue(def.getType(), value));
}

public JsonNode encodeValues(Map<SettingDefinition<?>, SettingValue<?>> settings) {
return settings.entrySet().stream()
.sorted(comparator)
.collect(nodeFactory::objectNode, this::encodeValue, ObjectNode::setAll);
return settings.entrySet().stream().sorted(comparator).collect(nodeFactory::objectNode, this::encodeValue,
ObjectNode::setAll);
}

private TextNode textNode(Object value) {
return nodeFactory.textNode(String.valueOf(value));
}

private static class SettingDefinitionComparator implements Comparator<Entry<SettingDefinition<?>, SettingValue<?>>> {
private static class SettingDefinitionComparator
implements Comparator<Entry<SettingDefinition<?>, SettingValue<?>>>, Serializable {

private static final long serialVersionUID = 1688892939717761041L;

@Override
public int compare(Entry<SettingDefinition<?>, SettingValue<?>> o1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public TextValue(String value) {
super();
super.setValue(value);
}

public TextValue(SweText value) {
super();
super.setValue(value.getValue());
Expand Down

0 comments on commit 919f95f

Please sign in to comment.