001package jmri.jmrix.loconet.usb_dcs210Plus;
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", "HSM_HIDING_METHOD"},
012    justification = "Desired pattern is repeated class names with package-level access to members")
013
014@javax.annotation.concurrent.Immutable
015
016/**
017 * Provides standard access for resource bundles in a package.
018 *
019 * Convention is to provide a subclass of this name in each package, working off
020 * the local resource bundle name.
021 * <p>
022 * Based on loconet.pr3.Bundle.java
023 *
024 * @author Bob Jacobsen Copyright (C) 2012
025 * @author B. Milhaupt Copyright (C) 2019
026 * @since 3.3.1
027 */
028public class Bundle extends jmri.jmrix.loconet.Bundle {
029
030    @CheckForNull
031    private static final String name = "jmri.jmrix.loconet.usb_dcs210Plus.UsbDcs210PlusBundle"; // NOI18N
032
033    //
034    // below here is boilerplate to be copied exactly
035    //
036    /**
037     * Provides a translated string for a given key from the package resource
038     * bundle or parent.
039     * <p>
040     * Note that this is intentionally package-local access.
041     *
042     * @param key Bundle key to be translated
043     * @return Internationalized text
044     */
045    static String getMessage(String key) {
046        return getBundle().handleGetMessage(key);
047    }
048
049    /**
050     * Merges user data with a translated string for a given key from the
051     * package resource bundle or parent.
052     * <p>
053     * Uses the transformation conventions of the Java MessageFormat utility.
054     * <p>
055     * Note that this is intentionally package-local access.
056     *
057     * @see java.text.MessageFormat
058     * @param key  Bundle key to be translated
059     * @param subs One or more objects to be inserted into the message
060     * @return Internationalized text
061     */
062    static String getMessage(String key, Object... subs) {
063        return getBundle().handleGetMessage(key, subs);
064    }
065
066    /**
067     * Merges user data with a translated string for a given key in a given
068     * locale from the package resource bundle or parent.
069     * <p>
070     * Uses the transformation conventions of the Java MessageFormat utility.
071     * <p>
072     * Note that this is intentionally package-local access.
073     *
074     * @see java.text.MessageFormat
075     * @param locale The locale to be used
076     * @param key    Bundle key to be translated
077     * @param subs   One or more objects to be inserted into the message
078     * @return Internationalized text
079     */
080    static String getMessage(Locale locale, String key, Object... subs) {
081        return getBundle().handleGetMessage(locale, key, subs);
082    }
083
084
085    private final static Bundle b = new Bundle();
086
087    @Override
088    @CheckForNull
089    protected String bundleName() {
090        return name;
091    }
092
093    protected static jmri.Bundle getBundle() {
094        return b;
095    }
096
097    @Override
098    protected String retry(Locale locale, String key) {
099        return super.getBundle().handleGetMessage(locale,key);
100    }
101
102}