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)); } }