Class AbstractI18NBean<T extends BeanTranslation>

    • Constructor Detail

      • AbstractI18NBean

        protected AbstractI18NBean()
    • Method Detail

      • getTranslationType

        protected abstract Class<T> getTranslationType()
      • getName

        public String getName()
        Gets the name of the bean in the language defined by the getLanguage() property.
        Specified by:
        getName in interface Nameable
        Returns:
        a short description about the bean.
      • setName

        public void setName​(String name)
        Sets the name of the bean in the language defined by the getLanguage() property.
        Parameters:
        name - the name of the bean.
      • getDescription

        public final String getDescription()
        Gets the description about the bean in the language defined by the getLanguage() property.
        Specified by:
        getDescription in interface Nameable
        Returns:
        a short description about the bean.
      • setDescription

        public final void setDescription​(String description)
        Gets the description about the bean in the language defined by the getLanguage() property.
        Parameters:
        description - a short description about the bean.
      • getName

        public String getName​(String language)
        Gets the name of the bean in the given language. This method is a shortcut of the following code:
         myBean.getTranslation(language).getName();
         
        Parameters:
        language - the ISO 631-1 code of the language
        Returns:
        the name of the bean in the specified language.
      • getDescription

        public String getDescription​(String language)
        Gets the description about the bean in the given language. This method is a shortcut of the following code:
         myBean.getTranslation(language).getDescription();
         
        Parameters:
        language - the ISO 631-1 code of the language
        Returns:
        the description about the bean in the specified language.
      • getLanguage

        public String getLanguage()
      • setLanguage

        public void setLanguage​(String language)
        Description copied from interface: I18NBean
        Sets the language in which the default values of the textual properties of the bean are set. By default, the language of those values are in the language defined by the I18n.getDefaultLanguage() method
        Specified by:
        setLanguage in interface I18NBean<T extends BeanTranslation>
        Parameters:
        language - the language.
      • isRemoveTranslation

        public boolean isRemoveTranslation()
      • getTranslationId

        public String getTranslationId()
      • setTranslationId

        public void setTranslationId​(String translationId)
        Description copied from interface: I18NBean
        Sets a unique identifier for the translation by default of the bean (the default values of the textual properties of the bean).
        Specified by:
        setTranslationId in interface I18NBean<T extends BeanTranslation>
        Parameters:
        translationId - a unique identifier of the default translation.
      • getTranslations

        public Map<String,​T> getTranslations()
        Description copied from interface: I18NBean
        Gets all the actually translations handled by this bean.
        Specified by:
        getTranslations in interface I18NBean<T extends BeanTranslation>
        Returns:
        a map with as key the ISO 631-1 code of a language and as value the translation in that language.
      • getClonedTranslations

        public Map<String,​T> getClonedTranslations()
        Gets cloned translations.
        This is useful on copy/paste operations.
        Returns:
        a clone of getTranslations() result.
      • setTranslations

        public void setTranslations​(Map<String,​T> translations)
      • setTranslations

        public void setTranslations​(Collection<T> translations)
      • getTranslation

        public T getTranslation​(String language)
        Gets a possible translation for the specified language. If no such translation exists in the given language then browse for a language for which a translation exists. This method will return always a translation; indeed in the case there is no translation in whatever supported language, then a default translation with the actual bean's properties is returned.
        Specified by:
        getTranslation in interface Translatable
        Parameters:
        language - the ISO 631-1 code of the language.
        Returns:
        a translation. Never null.
      • addTranslation

        public void addTranslation​(T translation)
      • getLanguageToDisplay

        public String getLanguageToDisplay​(String language)