summaryrefslogtreecommitdiff
path: root/src/main/java/com/lumaserv/bgp/protocol/SAFI.java
blob: 5fa6b99fba7f04570e21fc6ae2bd83519630f1f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.lumaserv.bgp.protocol;

import java.util.EnumSet;

import lombok.Getter;
import lombok.AllArgsConstructor;

@AllArgsConstructor
@Getter
public enum SAFI {
    UNICAST(1, "NLRI Unicast"),
    MULTICAST(2, "NLRI Multicast");

    int value;
    String desc;

    public static SAFI fromInteger(int value) {
        return EnumSet.allOf(SAFI.class).stream().filter(e -> e.getValue() == value).findAny().orElseThrow(
                () -> new IllegalArgumentException("unknown subsequent address family: " + value));
    }
}