package cz.moneta.test.harness.messaging.model;

import java.util.Locale;
import java.util.Optional;

public enum MqMessageFormat {
    JSON,
    XML,
    EBCDIC_870,
    UTF8_1208;

    public static MqMessageFormat fromConfig(String value, MqMessageFormat defaultValue) {
        return Optional.ofNullable(value)
                .map(v -> v.toUpperCase(Locale.ROOT).replace('-', '_'))
                .map(MqMessageFormat::valueOf)
                .orElse(defaultValue);
    }
}
