001/*
002 * #%L
003 * GwtBootstrap3
004 * %%
005 * Copyright (C) 2015 GwtBootstrap3
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 * 
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 * 
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package gwt.material.design.client.base.validator;
021
022/**
023 * Mixin for looking up validation messages. This can be replaced with your own version by using a
024 * "replace-with" statment in the gwt module file.
025 * <p>
026 * Example:
027 * <p>
028 * <pre>
029 * {@code
030 * <replace-with class="...CustomValidatorMessageMixin">
031 *     <when-type-is class="org.gwtbootstrap3.client.ui.form.validator.ValidatorMessageMixin" />
032 * </replace-with>
033 * }
034 * </pre>
035 *
036 * @author Steven Jardine
037 */
038public interface ValidatorMessageMixin {
039
040    /**
041     * Lookup the message using the supplied key.
042     *
043     * @param key the key.
044     * @return the message associated with the given key.
045     */
046    String lookup(String key);
047
048    /**
049     * Lookup a message using the given key and replace the arguments in the given message with the supplied
050     * values.
051     * <p>
052     * <pre>
053     * {@code
054     * Message:
055     * {1} is a {2}
056     *
057     * Call:
058     * lookup("key", "This", "test.");
059     *
060     * Returns:
061     * This is a test.
062     * }
063     * </pre>
064     *
065     * @param key       the key
066     * @param msgValues the values used in the message.
067     * @return the message associated with the given key with the message values replaced.
068     */
069    String lookup(String key, Object[] msgValues);
070
071}