/** * Transforms the given {@link List} of {@link KeyValuePair}'s to a {@link Map}. * * @param <K> * The generic type of the key * @param <V> * The generic type of the value * @param list * the list * @return the new map. */ public static <K, V> Map<K, V> toMap(final Collection<KeyValuePair<K, V>> list) { final Map<K, V> map = new HashMap<>(); for (KeyValuePair<K, V> keyValuePair : list) { map.put(keyValuePair.getKey(), keyValuePair.getValue()); } return map; }
/** * Transforms the given {@link Properties} to a list of {@link KeyValuePair}'s. * * @param properties * the properties * @return the new list with the {@link KeyValuePair}'s. */ public static List<KeyValuePair<String, String>> toKeyValuePairs(final Properties properties) { final List<KeyValuePair<String, String>> list = new ArrayList<>(); for (final Entry<Object, Object> entry : properties.entrySet()) { list.add(KeyValuePair.<String, String> builder().key((String)entry.getKey()) .value((String)entry.getValue()).build()); } return list; }
/** * Transforms the given {@link Map} to a list of {@link KeyValuePair}'s. * * @param <K> * The generic type of the key * @param <V> * The generic type of the value * @param map * the map * @return the new list with the {@link KeyValuePair}'s. */ public static <K, V> List<KeyValuePair<K, V>> toKeyValuePairs(final Map<K, V> map) { final List<KeyValuePair<K, V>> list = new ArrayList<>(); for (final Entry<K, V> entry : map.entrySet()) { list.add( KeyValuePair.<K, V> builder().key(entry.getKey()).value(entry.getValue()).build()); } return list; }
@Override protected void handleFile(final File file, final int depth, final Collection<File> results) throws IOException { final Locale locale = LocaleResolver.resolveLocale(file, defaultLocale, false); propertiesList .add(KeyValuePair.<File, Locale> builder().key(file).value(locale).build()); } };
/** * {@inheritDoc} */ @Override public Response getString(String bundleappname, String baseName, String locale, String key) { final ResourcebundleService resourcebundleService = getDomainService(); final BundleApplication bundleApplication = getDomainService().find(bundleappname); final String result = resourcebundleService.getString(bundleApplication, baseName, locale, key); return Response.ok(KeyValuePair.builder().key(key).value(result).build()).build(); }
/** * {@inheritDoc} */ @Override public Response getString(String bundleappname, String baseName, String locale, String key, String[] params) { final ResourcebundleService resourcebundleService = getDomainService(); final BundleApplication bundleApplication = getDomainService().find(bundleappname); final String result = resourcebundleService.getString(bundleApplication, baseName, locale, key, params); return Response.ok(KeyValuePair.builder().key(key).value(result).build()).build(); }
/** * {@inheritDoc} */ @Override public Response getResponseString(String bundleappname, String baseName, String locale, String key) { final ResourcebundleService resourcebundleService = getDomainService(); final BundleApplication bundleApplication = getDomainService().find(bundleappname); final String result = resourcebundleService.getString(bundleApplication, baseName, locale, key); return Response.ok(KeyValuePair.builder().key(key).value(result).build()).build(); }
/** * {@inheritDoc} */ @Override public List<BundleNames> importProperties(BundleApplications bundleApplication, List<KeyValuePair<File, Locale>> foundProperties) throws IOException { final List<BundleNames> list = new ArrayList<>(); for (final KeyValuePair<File, Locale> entry : foundProperties) { final File propertiesFile = entry.getKey(); final Locale locale = entry.getValue(); final String bundlename = LocaleResolver.resolveBundlename(propertiesFile); final Properties properties = PropertiesExtensions.loadProperties(propertiesFile); final BundleNames bundleNames = updateProperties(bundleApplication, properties, bundlename, locale, false); list.add(bundleNames); bundleApplication = bundleApplicationsService.merge(bundleApplication); } return list; }