summaryrefslogtreecommitdiff
path: root/src/main/java/com/benburwell/planes/sbs/MessageType.java
blob: a2ecc660f3cf8bdc92031a4adc87e2db3ddbd27c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.benburwell.planes.sbs;

/**
 * Created by ben on 11/15/16.
 */
public enum MessageType {
    SELECTION_CHANGE("SEL"),
    NEW_ID("ID"),
    NEW_AIRCRAFT("AIR"),
    STATUS_CHANGE("STA"),
    CLICK("CLK"),
    TRANSMISSION("MSG");

    private String code;
    MessageType(String code) {
        this.code = code;
    }

    public String getCode() {
        return this.code;
    }

    public static MessageType parse(String messageType) throws UnrecognizedMessageTypeException {
        for (MessageType type : MessageType.values()) {
            if (type.getCode().equals(messageType)) {
                return type;
            }
        }
        throw new UnrecognizedMessageTypeException(messageType);
    }
}