001package jmri.jmrix.cmri.serial.cmrinetmanager;
002
003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
004import java.util.Locale;
005import javax.annotation.CheckReturnValue;
006import javax.annotation.CheckForNull;
007import javax.annotation.ParametersAreNonnullByDefault;
008
009@ParametersAreNonnullByDefault
010@CheckReturnValue
011@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_SUPERCLASS", justification = "Desired pattern is repeated class names with package-level access to members")
012
013@javax.annotation.concurrent.Immutable
014
015/**
016 * Provides standard access for resource bundles in a package.
017 *
018 * Convention is to provide a subclass of this name in each package, working off
019 * the local resource bundle name.
020 *
021 * @author Bob Jacobsen Copyright (C) 2012
022 * @author Chuck Catania Copyright (C) 2017
023 * @since 3.3.1
024 */
025public class Bundle extends jmri.jmrix.cmri.serial.Bundle {
026
027    @CheckForNull
028    private static final String name = "jmri.jmrix.cmri.serial.cmrinetmanager.CMRInetManagerBundle"; // c2
029
030    //
031    // below here is boilerplate to be copied exactly
032    //
033    /**
034     * Provides a translated string for a given key from the package resource
035     * bundle or parent.
036     * <p>
037     * Note that this is intentionally package-local access.
038     *
039     * @param key Bundle key to be translated
040     * @return Internationalized text
041     */
042    static String getMessage(String key) {
043        return getBundle().handleGetMessage(key);
044    }
045
046    /**
047     * Provides a translated string for a given key in a given locale from the
048     * package resource bundle or parent.
049     * <p>
050     * Note that this is intentionally package-local access.
051     *
052     * @param locale The locale to be used
053     * @param key    Bundle key to be translated
054     * @return Internationalized text
055     */
056    static String getMessage(Locale locale, String key) {
057        return getBundle().handleGetMessage(locale, key);
058    }
059
060    /**
061     * Merges user data with a translated string for a given key from the
062     * package resource bundle or parent.
063     * <p>
064     * Uses the transformation conventions of the Java MessageFormat utility.
065     * <p>
066     * Note that this is intentionally package-local access.
067     *
068     * @see java.text.MessageFormat
069     * @param key  Bundle key to be translated
070     * @param subs One or more objects to be inserted into the message
071     * @return Internationalized text
072     */
073    static String getMessage(String key, Object... subs) {
074        return getBundle().handleGetMessage(key, subs);
075    }
076
077    /**
078     * Merges user data with a translated string for a given key in a given
079     * locale from the package resource bundle or parent.
080     * <p>
081     * Uses the transformation conventions of the Java MessageFormat utility.
082     * <p>
083     * Note that this is intentionally package-local access.
084     *
085     * @see java.text.MessageFormat
086     * @param locale The locale to be used
087     * @param key    Bundle key to be translated
088     * @param subs   One or more objects to be inserted into the message
089     * @return Internationalized text
090     */
091    static String getMessage(Locale locale, String key, Object... subs) {
092        return getBundle().handleGetMessage(locale, key, subs);
093    }
094
095    private final static Bundle b = new Bundle();
096
097    @Override
098    @CheckForNull
099    protected String bundleName() {
100        return name;
101    }
102
103    protected static jmri.Bundle getBundle() {
104        return b;
105    }
106
107    @Override
108    protected String retry(Locale locale, String key) {
109        return super.getBundle().handleGetMessage(locale,key);
110    }
111
112}