/*
 * Copyright 2006-2011 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.citrusframework.message;

/**
 * Enumeration for message protocol types used in test cases.
 *
 * @author Christoph Deppisch
 */
public enum MessageType {
    UNSPECIFIED,
    XML,
    XHTML,
    CSV,
    JSON,
    PLAINTEXT,
    BINARY,
    BINARY_BASE64,
    GZIP,
    GZIP_BASE64,
    MSCONS;

    /**
     * Check if this message type name is matching a enum value.
     *
     * @param messageTypeName
     * @return
     */
    public static boolean knows(String messageTypeName) {
        for (MessageType messageType: MessageType.values()) {
            if (messageType.toString().equalsIgnoreCase(messageTypeName)) {
                return true;
            }
        }

        return false;
    }

    /**
     * Checks for the given message type to be handled as binary content.
     * @param messageType
     * @return
     */
    public static boolean isBinary(String messageType) {
        return MessageType.GZIP.name().equalsIgnoreCase(messageType)
                || MessageType.BINARY.name().equalsIgnoreCase(messageType);
    }
}
