/** * Returns a human-readable string representation of the given object. * * @see java.lang.Object#toString() * @param o * the object to represent as string * @return a string representation of the object */ public static String toString(MonolingualTextValue o) { return "\"" + o.getText().replace("\"", "\\\"") + "\" (" + o.getLanguageCode() + ")"; }
/** * Returns the string label for the given language code, or null if there is * no label for this code. This is a convenience method for accessing the * data that can be obtained via {@link #getLabels()}. * * @param languageCode * a string that represents language * @return the label string or null if it does not exists */ default String findLabel(String languageCode) { MonolingualTextValue value = this.getLabels().get(languageCode); return (value != null) ? value.getText() : null; }
/** * Returns a human-readable string representation of the given object. * * @see java.lang.Object#toString() * @param o * the object to represent as string * @return a string representation of the object */ public static String toString(MonolingualTextValue o) { return "\"" + o.getText().replace("\"", "\\\"") + "\" (" + o.getLanguageCode() + ")"; }
/** * Copy constructor. * * @param mltv * the object to copy the data from */ @Deprecated public TermImpl(MonolingualTextValue mltv) { this(mltv.getLanguageCode(), mltv.getText()); }
/** * Copy constructor. * * @param mltv * the object to copy the data from */ @Deprecated public TermImpl(MonolingualTextValue mltv) { this(mltv.getLanguageCode(), mltv.getText()); }
@Override public WikidataValue visit(MonolingualTextValue value) { return WikidataValue.forString(value.getText()); }
/** * Returns the string description for the given language code, or null if * there is no description for this code. This is a convenience method for * accessing the data that can be obtained via {@link #getDescriptions()}. * * @param languageCode * a string that represents language * @return the description string or null if it does not exists */ default String findDescription(String languageCode) { MonolingualTextValue value = this.getDescriptions().get(languageCode); return (value != null) ? value.getText() : null; }
/** * Returns the string description for the given language code, or null if * there is no description for this code. This is a convenience method for * accessing the data that can be obtained via {@link #getDescriptions()}. * * @param languageCode * a string that represents language * @return the description string or null if it does not exists */ default String findDescription(String languageCode) { MonolingualTextValue value = this.getDescriptions().get(languageCode); return (value != null) ? value.getText() : null; }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(MonolingualTextValue o) { int result; result = o.getLanguageCode().hashCode(); result = prime * result + o.getText().hashCode(); return result; }
private static Map<String, MonolingualTextValue> constructTermMap(List<MonolingualTextValue> terms) { Map<String, MonolingualTextValue> map = new HashMap<>(); for(MonolingualTextValue term : terms) { String language = term.getLanguageCode(); if(map.containsKey(language)) { throw new IllegalArgumentException("Multiple terms provided for the same language."); } // We need to make sure the terms are of the right type, otherwise they will not // be serialized correctly. map.put(language, (term instanceof TermImpl) ? term : new TermImpl(term.getLanguageCode(), term.getText())); } return map; }
private static Map<String, MonolingualTextValue> constructTermMap(List<MonolingualTextValue> terms) { Map<String, MonolingualTextValue> map = new HashMap<>(); for(MonolingualTextValue term : terms) { String language = term.getLanguageCode(); if(map.containsKey(language)) { throw new IllegalArgumentException("Multiple terms provided for the same language."); } // We need to make sure the terms are of the right type, otherwise they will not // be serialized correctly. map.put(language, (term instanceof TermImpl) ? term : new TermImpl(term.getLanguageCode(), term.getText())); } return map; }
private static Map<String, MonolingualTextValue> constructTermMap(List<MonolingualTextValue> terms) { Map<String, MonolingualTextValue> map = new HashMap<>(); for(MonolingualTextValue term : terms) { String language = term.getLanguageCode(); if(map.containsKey(language)) { throw new IllegalArgumentException("Multiple terms provided for the same language."); } // We need to make sure the terms are of the right type, otherwise they will not // be serialized correctly. map.put(language, (term instanceof TermImpl) ? term : new TermImpl(term.getLanguageCode(), term.getText())); } return map; }
private static Map<String, MonolingualTextValue> constructTermMap(List<MonolingualTextValue> terms) { Map<String, MonolingualTextValue> map = new HashMap<>(); for(MonolingualTextValue term : terms) { String language = term.getLanguageCode(); if(map.containsKey(language)) { throw new IllegalArgumentException("Multiple terms provided for the same language."); } // We need to make sure the terms are of the right type, otherwise they will not // be serialized correctly. map.put(language, (term instanceof TermImpl) ? term : new TermImpl(term.getLanguageCode(), term.getText())); } return map; }
private static Map<String, MonolingualTextValue> constructTermMap(List<MonolingualTextValue> terms) { Map<String, MonolingualTextValue> map = new HashMap<>(); for(MonolingualTextValue term : terms) { String language = term.getLanguageCode(); if(map.containsKey(language)) { throw new IllegalArgumentException("Multiple terms provided for the same language."); } // We need to make sure the terms are of the right type, otherwise they will not // be serialized correctly. map.put(language, (term instanceof TermImpl) ? term : new TermImpl(term.getLanguageCode(), term.getText())); } return map; }
/** * Creates a monolingual value that is suitable for JSON serialization. * @param monolingualTextValue * target monolingual value for serialization * @return Jackson implementation that is serialized appropriately */ protected TermImpl monolingualToJackson(MonolingualTextValue monolingualTextValue) { return new TermImpl(monolingualTextValue.getLanguageCode(), monolingualTextValue.getText()); } }
/** * We need to make sure the terms are of the right type, otherwise they will not be serialized correctly. */ private static MonolingualTextValue toTerm(MonolingualTextValue term) { return term instanceof TermImpl ? term : new TermImpl(term.getLanguageCode(), term.getText()); }
/** * We need to make sure the terms are of the right type, otherwise they will not be serialized correctly. */ private static MonolingualTextValue toTerm(MonolingualTextValue term) { return term instanceof TermImpl ? term : new TermImpl(term.getLanguageCode(), term.getText()); }
/** * Copies a {@link MonolingualTextValue}. This method is not affected by the * language filter option (see * {@link DatamodelConverter#setOptionLanguageFilter(Set)}). * * @param object * object to copy * @return copied object */ public MonolingualTextValue copy(MonolingualTextValue object) { return dataObjectFactory.getMonolingualTextValue(object.getText(), object.getLanguageCode()); }
/** * Creates a monolingual value that is suitable for JSON serialization. * @param monolingualTextValue * target monolingual value for serialization * @return Jackson implementation that is serialized appropriately */ protected TermImpl monolingualToJackson(MonolingualTextValue monolingualTextValue) { return new TermImpl(monolingualTextValue.getLanguageCode(), monolingualTextValue.getText()); } }
/** * Copies a {@link MonolingualTextValue}. This method is not affected by the * language filter option (see * {@link DatamodelConverter#setOptionLanguageFilter(Set)}). * * @param object * object to copy * @return copied object */ public MonolingualTextValue copy(MonolingualTextValue object) { return dataObjectFactory.getMonolingualTextValue(object.getText(), object.getLanguageCode()); }