com.github.aynu.mosir.core.standard.util.MessageHelper.java Source code

Java tutorial

Introduction

Here is the source code for com.github.aynu.mosir.core.standard.util.MessageHelper.java

Source

// ----------------------------------------------------------------------------
// Copyright (C) Aynu Evolution Laboratory. All rights reserved.
// GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
// http://www.gnu.org/licenses/gpl-3.0-standalone.html
// ----------------------------------------------------------------------------
package com.github.aynu.mosir.core.standard.util;

import java.text.MessageFormat;
import org.apache.commons.lang3.Validate;

/**
 * 
 * @author nilcy
 */
public final class MessageHelper {
    /**  */
    private static final PropertiesHelper DEF = new PropertiesHelper(ConfigHelper.MESSAGE_BASENAME);

    /** ? */
    private MessageHelper() {
    }

    /**
     * 
     * @param message 
     * @param values 
     * @return 
     */
    public static String createMessage(final String message, final Object... values) {
        Validate.notBlank(message);
        return MessageFormat.format(message, values);
    }

    /**
     * 
     * @param key 
     * @param values 
     * @return 
     */
    public static String templateMessage(final String key, final Object... values) {
        Validate.notBlank(key);
        return createMessage(DEF.getText(key), values);
    }
}