@Override public JsonNode serialize(final Set<T> t) { final Set<String> keySet = t.stream().map(elem -> elem.getKey()).collect(toSet()); return mapper().valueToTree(keySet); } }
@Override public JsonNode serialize(final T t) { return mapper().valueToTree(t.getKey()); } }
@Override public JsonNode serialize(final Set<T> t) { final Set<String> keySet = t.stream().map(elem -> elem.getKey()).collect(toSet()); return mapper().valueToTree(keySet); } }
@Override public JsonNode serialize(final T t) { return mapper().valueToTree(t.getKey()); } }
@Override public JsonNode serialize(final Set<T> t) { final Set<String> keySet = t.stream().map(elem -> elem.getKey()).collect(toSet()); return mapper().valueToTree(keySet); } }
@Override public JsonNode serialize(final Set<T> t) { final Set<String> keySet = t.stream().map(elem -> elem.getKey()).collect(toSet()); return mapper().valueToTree(keySet); } }
@Override public JsonNode serialize(final T t) { return mapper().valueToTree(t.getKey()); } }
@Override public JsonNode serialize(final Set<T> t) { final Set<String> keySet = t.stream().map(elem -> elem.getKey()).collect(toSet()); return mapper().valueToTree(keySet); } }
public static <T> AttributeDraft of(final String name, final T value) { final AttributeDraft result; if (value instanceof LocalizedEnumValue) { result = of(name, ((LocalizedEnumValue) value).getKey()); } else if (value instanceof EnumValue) { result = of(name, ((EnumValue) value).getKey()); } else if (value instanceof Set) { final Set<?> set = (Set<?>) value; if (!set.isEmpty()) { final Object setValue = set.stream().findAny().get(); if (setValue instanceof LocalizedEnumValue || setValue instanceof EnumValue) { //WithKey is a interface the enum like implement final Set<String> newValues = set.stream().map(x -> ((WithKey) x).getKey()).collect(toSet()); result = of(name, newValues); } else { result = of(name, SphereJsonUtils.toJsonNode(value)); } } else { result = of(name, SphereJsonUtils.toJsonNode(value)); } } else { result = of(name, SphereJsonUtils.toJsonNode(value)); } return result; }
static <T> AttributeDraft of(final String name, final T value) { final AttributeDraft result; if (value instanceof LocalizedEnumValue) { result = of(name, ((LocalizedEnumValue) value).getKey()); } else if (value instanceof EnumValue) { result = of(name, ((EnumValue) value).getKey()); } else if (value instanceof Set) { final Set<?> set = (Set<?>) value; if (!set.isEmpty()) { final Object setValue = set.stream().findAny().get(); if (setValue instanceof LocalizedEnumValue || setValue instanceof EnumValue) { //WithKey is a interface the enum like implement final Set<String> newValues = set.stream().map(x -> ((WithKey) x).getKey()).collect(toSet()); result = of(name, newValues); } else { result = of(name, SphereJsonUtils.toJsonNode(value)); } } else { result = of(name, SphereJsonUtils.toJsonNode(value)); } } else { result = of(name, SphereJsonUtils.toJsonNode(value)); } return result; }
static <T> AttributeDraft of(final String name, final T value) { final AttributeDraft result; if (value instanceof LocalizedEnumValue) { result = of(name, ((LocalizedEnumValue) value).getKey()); } else if (value instanceof EnumValue) { result = of(name, ((EnumValue) value).getKey()); } else if (value instanceof Set) { final Set<?> set = (Set<?>) value; if (!set.isEmpty()) { final Object setValue = set.stream().findAny().get(); if (setValue instanceof LocalizedEnumValue || setValue instanceof EnumValue) { //WithKey is a interface the enum like implement final Set<String> newValues = set.stream().map(x -> ((WithKey) x).getKey()).collect(toSet()); result = of(name, newValues); } else { result = of(name, SphereJsonUtils.toJsonNode(value)); } } else { result = of(name, SphereJsonUtils.toJsonNode(value)); } } else { result = of(name, SphereJsonUtils.toJsonNode(value)); } return result; }