001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache license, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the license for the specific language governing permissions and
015 * limitations under the license.
016 */
017package org.apache.logging.log4j.message;
018
019/**
020 * Factory for the simplest possible implementation of Message, the Message String given as the constructor argument.
021 * <p>
022 * Creates {@link StringFormattedMessage} instances for
023 * {@link #newMessage(String, Object...)}.
024 * </p>
025 * <p>
026 * This class is immutable.
027 * </p>
028 * @since 2.5
029 */
030public final class SimpleMessageFactory extends AbstractMessageFactory {
031
032    /**
033     * Instance of StringFormatterMessageFactory.
034     */
035    public static final SimpleMessageFactory INSTANCE = new SimpleMessageFactory();
036
037    private static final long serialVersionUID = 1L;
038
039    /**
040     * Creates {@link StringFormattedMessage} instances.
041     *
042     * @param message
043     *            The message pattern.
044     * @param params
045     *            The parameters to the message.
046     * @return The Message.
047     *
048     * @see MessageFactory#newMessage(String, Object...)
049     */
050    @Override
051    public Message newMessage(final String message, final Object... params) {
052        return new SimpleMessage(message);
053    }
054}