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