All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.cedarsoft.devtools.CoreMessageHandler Maven / Gradle / Ivy

The newest version!
package eu.cedarsoft.devtools;

import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.PropertyKey;

import java.text.MessageFormat;
import java.util.ResourceBundle;

/**
 * Handler for the core messages
 */
public class CoreMessageHandler {
  @NotNull
  @NonNls
  private static final String CORE_RESOURCE_BUNDLE_NAME = "core";
  private static final ResourceBundle BUNDLE = ResourceBundle.getBundle( CORE_RESOURCE_BUNDLE_NAME );

  private CoreMessageHandler() {
  }

  /**
   * Return the translated messages for the given key
   *
   * @param key the key
   * @return the translated value
   */
  @NotNull
  public static String get( @PropertyKey( resourceBundle = CORE_RESOURCE_BUNDLE_NAME ) @NotNull String key ) {
    return BUNDLE.getString( key );
  }

  /**
   * Returns the translated message
   *
   * @param key       the key
   * @param arguments the arguments
   * @return the translated message
   */
  @SuppressWarnings( {"OverloadedVarargsMethod"} )
  public static String get( @PropertyKey( resourceBundle = CORE_RESOURCE_BUNDLE_NAME ) @NotNull String key, @NotNull Object... arguments ) {
    return MessageFormat.format( BUNDLE.getString( key ), arguments );
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy