package com.lumaserv.bgp.protocol; import java.util.EnumSet; import lombok.Getter; import lombok.AllArgsConstructor; @AllArgsConstructor @Getter public enum AFI { IPV4(1, "IPv4"), IPV6(2, "IPv6"); int value; String desc; public static AFI fromInteger(int value) { return EnumSet.allOf(AFI.class).stream().filter(e -> e.getValue() == value).findAny().orElseThrow( () -> new IllegalArgumentException("unknown address family: " + value)); } }