<commit_before>package org.dasein.cloud.platform.support;

/**
 * @author <NAME>
 * @since 26.08.2014
 */
public enum TicketSeverity {
    LOW(1),
    NORMAL(2),
    HIGH(3),
    URGENT(4),
    CRITICAL(5),
    UNKNOWN(-1);

    private Integer num;

    TicketSeverity(Integer num) {
        this.num = num;
    }

    public static TicketSeverity valueByPriority(Integer value) {
        for (TicketSeverity severity : values()) {
            if (severity.num.equals(value)) {
                return severity;
            }
        }
        return UNKNOWN;//default
    }
}<commit_msg>valueOf fix of ticketSeverity (#1106)<commit_after>package org.dasein.cloud.platform.support;

import org.dasein.cloud.CloudException;

/**
 * @author <NAME>
 * @since 26.08.2014
 */
public enum TicketSeverity {
    LOW(1),
    NORMAL(2),
    HIGH(3),
    URGENT(4),
    CRITICAL(5),
    UNKNOWN(-1);

    private Integer num;

    TicketSeverity(Integer num) {
        this.num = num;
    }

    public static TicketSeverity valueOf(Object value) throws CloudException {
        if (value != null && isString(value)) {
            TicketSeverity validateValue = validateValue(String.valueOf(value));
            if (validateValue != null) {
                return validateValue;
            } else {
                for (TicketSeverity severity : values()) {
                    if (severity.name().equalsIgnoreCase(String.valueOf(value))) {
                        return severity;
                    }
                }
            }
        }
        throw new CloudException("Invalid value for TicketSeverity " + value);
    }

    public static TicketSeverity valueByPriority(Integer value) {
        for (TicketSeverity severity : values()) {
            if (severity.num.equals(value)) {
                return severity;
            }
        }
        return UNKNOWN;//default
    }

    public static boolean isString(Object o) {
        return o.getClass().equals(String.class);
    }

    public static TicketSeverity validateValue(String value) {
        try {
            return valueOf(TicketSeverity.class, value);
        } catch (IllegalArgumentException ex) {
            return null;
        } catch (NullPointerException npe) {
            return null;
        }
    }
}
{'fraction_non_alphanumeric': 0.10657894736842105, 'fraction_numerical': 0.014035087719298246, 'mean_word_length': 1.9470284237726099, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7060022', 'n_tokens_mistral': 706, 'n_tokens_neox': 656, 'n_words': 141}