private Map<Integer, String> readRestSerializerClassNames(final Element element) { @SuppressWarnings ("unchecked") final List<Element> restSerializerElements = element.elements(REST_SERIALIZER_ELEMENT_NAME); final Iterable<Map.Entry<Integer, String>> entries = Iterables.transform(restSerializerElements, new Function<Element, Map.Entry<Integer, String>>() { @Override public Map.Entry<Integer, String> apply(@Nullable final Element element) { final Integer version = parseVersionNumber(getRequiredAttributeValue(element, VERSION_NUMBER_ARGUMENT_NAME)); final String className = getRequiredAttributeValue(element, SERIALIZER_CLASS_ARGUMENT_NAME); return Maps.immutableEntry(version, className); } }); // ImmutableMaps.toMap already checks that all keys are individual. try { return ImmutableMaps.toMap(entries); } catch (IllegalArgumentException e) { throw new PluginParseException(REST_SERIALIZER_ELEMENT_NAME + "'s " + VERSION_NUMBER_ARGUMENT_NAME + " can't be duplicated", e); } }
private ImmutableMap<String, String> getDashboardItemProperties(final Long id) { List<String> propertyKeys = jsonEntityPropertyManager.findKeys(DASHBOARD_ITEM_PROPERTY.getDbEntityName(), id); return ImmutableMaps.toMap(Iterables.collect(propertyKeys, new Function<String, Option<Map.Entry<String, String>>>() { @Override public Option<Map.Entry<String, String>> apply(final String propertyKey) { return Option.option(jsonEntityPropertyManager.get(DASHBOARD_ITEM_PROPERTY.getDbEntityName(), id, propertyKey)).map(new Function<EntityProperty, Map.Entry<String, String>>() { @Override public Map.Entry<String, String> apply(final EntityProperty entityProperty) { final String value = fromJsonString(entityProperty.getValue()); return Maps.immutableEntry(propertyKey, Strings.nullToEmpty(value)); } }); } })); }