/** * 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; }
@Override public List<KeyValuesPair<Country, Zipcode>> getCountriesToZipcodesList() { if (this.countryToZipcodeList == null) { this.countryToZipcodeList = new ArrayList<>(); List<KeyValuesPair<Countries, Zipcodes>> countriesToZipcodesMap = countriesService .getCountriesToZipcodesList(); for (KeyValuesPair<Countries, Zipcodes> entry : countriesToZipcodesMap) { countryToZipcodeList.add(KeyValuesPair.<Country, Zipcode> builder() .key(getMapper().toDomainObject(entry.getKey())) .values(getMapper().map(entry.getValues(), Zipcode.class)).build()); } } return this.countryToZipcodeList; }
/** * {@inheritDoc} */ @Override public Object getValueAt(final int rowIndex, final int columnIndex) { final Quattro<TL, TR, BL, BR> row = getData().get(rowIndex); switch (columnIndex) { case 0 : return row.getTopLeft(); case 1 : return row.getTopRight(); case 2 : return row.getBottomLeft(); case 3 : return row.getBottomRight(); default : return null; } }
/** * 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; }
/** * {@inheritDoc} */ @Override public List<KeyValuesPair<String, String>> getCountriesToFederalstatesAsStringList() { if (this.countriesToFederalstatesAsStringList == null) { this.countriesToFederalstatesAsStringList = new ArrayList<>(); List<KeyValuesPair<Countries, Federalstates>> countriesToFederalstatesList = getCountriesToFederalstatesList(); for (KeyValuesPair<Countries, Federalstates> entry : countriesToFederalstatesList) { Countries country = entry.getKey(); Collection<Federalstates> federalstates = entry.getValues(); List<String> fd = new ArrayList<String>(); for (Federalstates federalstate : federalstates) { fd.add(federalstate.getIso3166A2code()); } this.countriesToFederalstatesAsStringList.add(KeyValuesPair .<String, String> builder().key(country.getName()).values(fd).build()); } } return this.countriesToFederalstatesAsStringList; }
/** * {@inheritDoc} */ @Override public Object getValueAt(final int rowIndex, final int columnIndex) { final Triple<L, M, R> row = getData().get(rowIndex); switch (columnIndex) { case 0 : return row.getLeft(); case 1 : return row.getMiddle(); case 2 : return row.getRight(); default : return null; } }
/** * 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 public List<KeyValuesPair<Country, Zipcode>> getGermanCountriesToZipcodesList() { if (this.germanCountryToZipcodeList == null) { this.germanCountryToZipcodeList = new ArrayList<>(); List<KeyValuesPair<Countries, Zipcodes>> germanCountriesToZipcodesMap = countriesService .getGermanCountriesToZipcodesList(); for (KeyValuesPair<Countries, Zipcodes> entry : germanCountriesToZipcodesMap) { this.germanCountryToZipcodeList.add(KeyValuesPair.<Country, Zipcode> builder() .key(getMapper().toDomainObject(entry.getKey())) .values(getMapper().map(entry.getValues(), Zipcode.class)).build()); } } return this.germanCountryToZipcodeList; }
/** * {@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 List<KeyValuesPair<String, String>> getGermanCountriesToZipcodesAsStringList() { if (this.germanCountriesToZipcodesAsStringList == null) { this.germanCountriesToZipcodesAsStringList = new ArrayList<>(); List<KeyValuesPair<Countries, Zipcodes>> countriesToZipcodeMap = getGermanCountriesToZipcodesList(); for (KeyValuesPair<Countries, Zipcodes> entry : countriesToZipcodeMap) { Countries country = entry.getKey(); Collection<Zipcodes> zipcodes = entry.getValues(); List<String> zc = new ArrayList<String>(); for (Zipcodes zipcode : zipcodes) { zc.add(zipcode.getZipcode()); } this.germanCountriesToZipcodesAsStringList.add(KeyValuesPair .<String, String> builder().key(country.getName()).values(zc).build()); } } return this.germanCountriesToZipcodesAsStringList; }
/** * {@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 List<KeyValuesPair<String, String>> getCountriesToZipcodesAsStringList() { if (this.countriesToZipcodesAsStringList == null) { this.countriesToZipcodesAsStringList = new ArrayList<>(); List<KeyValuesPair<Countries, Zipcodes>> countriesToZipcodeList = getCountriesToZipcodesList(); for (KeyValuesPair<Countries, Zipcodes> entry : countriesToZipcodeList) { Countries country = entry.getKey(); Collection<Zipcodes> zipcodes = entry.getValues(); List<String> zc = new ArrayList<>(); for (Zipcodes zipcode : zipcodes) { zc.add(zipcode.getZipcode()); } ; this.countriesToZipcodesAsStringList.add(KeyValuesPair.<String, String> builder() .key(country.getName()).values(zc).build()); } } return this.countriesToZipcodesAsStringList; }
/** * {@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<KeyValuesPair<String, String>> getGermanCountriesToZipcodesAndCitiesAsStringList() { if (this.germanCountriesToZipcodesAndCitiesAsStringList == null) { this.germanCountriesToZipcodesAndCitiesAsStringList = new ArrayList<>(); List<KeyValuesPair<Countries, Zipcodes>> countriesToZipcodeMap = getGermanCountriesToZipcodesList(); for (KeyValuesPair<Countries, Zipcodes> entry : countriesToZipcodeMap) { Countries country = entry.getKey(); Collection<Zipcodes> zipcodes = entry.getValues(); List<String> zc = new ArrayList<String>(); for (Zipcodes zipcode : zipcodes) { zc.add(zipcode.getZipcode() + " " + zipcode.getCity()); zc.add(zipcode.getCity() + " " + zipcode.getZipcode()); } this.germanCountriesToZipcodesAndCitiesAsStringList.add(KeyValuesPair .<String, String> builder().key(country.getName()).values(zc).build()); } } return this.germanCountriesToZipcodesAndCitiesAsStringList; }