
com.belladati.sdk.impl.LocalizationImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk-java Show documentation
Show all versions of sdk-java Show documentation
The BellaDati SDK allows accessing a BellaDati server from 3rd-party applications using Java. This project contains the implementation for standard Java.
The newest version!
package com.belladati.sdk.impl;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import com.belladati.sdk.util.Localizable;
import com.fasterxml.jackson.databind.JsonNode;
class LocalizationImpl implements Localizable {
private final String name;
private final Map l10n;
LocalizationImpl(JsonNode json) {
this.name = json.get("name").asText();
Map l10n = new HashMap();
if (json.hasNonNull("localization")) {
JsonNode locNode = json.get("localization");
for (Iterator> iterator = locNode.fields(); iterator.hasNext();) {
Entry entry = iterator.next();
if (entry.getValue().isTextual()) {
l10n.put(entry.getKey().toLowerCase(Locale.ENGLISH), entry.getValue().asText());
}
}
}
this.l10n = Collections.unmodifiableMap(l10n);
}
@Override
public String getName(Locale locale) {
String loc = l10n.get(locale.getLanguage().toLowerCase(Locale.ENGLISH));
return loc != null ? loc : name;
}
@Override
public boolean hasLocalization(Locale locale) {
return l10n.containsKey(locale.getLanguage().toLowerCase(Locale.ENGLISH));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy