@Test(expected = BatfishException.class) public void testToIpProtocol_invalid() { Utils.toIpProtocol("crap"); }
@Nullable public static IpProtocol toIpProtocol(String ipProtocolAsString) { switch (ipProtocolAsString) { case "tcp": return IpProtocol.TCP; case "udp": return IpProtocol.UDP; case "icmp": return IpProtocol.ICMP; case "icmpv6": return IpProtocol.IPV6_ICMP; case "-1": return null; default: try { int ipProtocolAsInt = Integer.parseInt(ipProtocolAsString); return IpProtocol.fromNumber(ipProtocolAsInt); } catch (NumberFormatException e) { throw new BatfishException( "Could not convert AWS IP protocol: \"" + ipProtocolAsString + "\" to batfish Ip Protocol", e); } } }
Utils { @Nullable public static IpProtocol toIpProtocol(String ipProtocolAsString) { switch (ipProtocolAsString) { case "tcp": return IpProtocol.TCP; case "udp": return IpProtocol.UDP; case "icmp": return IpProtocol.ICMP; case "icmpv6": return IpProtocol.IPV6_ICMP; case "-1": return null; default: try { int ipProtocolAsInt = Integer.parseInt(ipProtocolAsString); return IpProtocol.fromNumber(ipProtocolAsInt); } catch (NumberFormatException e) { throw new BatfishException( "Could not convert AWS IP protocol: \"" + ipProtocolAsString + "\" to batfish Ip Protocol", e); } } } }
Utils { @Nullable public static IpProtocol toIpProtocol(String ipProtocolAsString) { switch (ipProtocolAsString) { case "tcp": return IpProtocol.TCP; case "udp": return IpProtocol.UDP; case "icmp": return IpProtocol.ICMP; case "icmpv6": return IpProtocol.IPV6_ICMP; case "-1": return null; default: try { int ipProtocolAsInt = Integer.parseInt(ipProtocolAsString); return IpProtocol.fromNumber(ipProtocolAsInt); } catch (NumberFormatException e) { throw new BatfishException( "Could not convert AWS IP protocol: \"" + ipProtocolAsString + "\" to batfish Ip Protocol", e); } } } private  Utils(); }
Utils { @Nullable public static IpProtocol toIpProtocol(String ipProtocolAsString) { switch (ipProtocolAsString) { case "tcp": return IpProtocol.TCP; case "udp": return IpProtocol.UDP; case "icmp": return IpProtocol.ICMP; case "icmpv6": return IpProtocol.IPV6_ICMP; case "-1": return null; default: try { int ipProtocolAsInt = Integer.parseInt(ipProtocolAsString); return IpProtocol.fromNumber(ipProtocolAsInt); } catch (NumberFormatException e) { throw new BatfishException( "Could not convert AWS IP protocol: \"" + ipProtocolAsString + "\" to batfish Ip Protocol", e); } } } private  Utils(); @Nullable static IpProtocol toIpProtocol(String ipProtocolAsString); static TraceElement getTraceElementForRule(@Nullable String ruleDescription); static TraceElement getTraceElementForSecurityGroup(String securityGroupName); }
Utils { @Nullable public static IpProtocol toIpProtocol(String ipProtocolAsString) { switch (ipProtocolAsString) { case "tcp": return IpProtocol.TCP; case "udp": return IpProtocol.UDP; case "icmp": return IpProtocol.ICMP; case "icmpv6": return IpProtocol.IPV6_ICMP; case "-1": return null; default: try { int ipProtocolAsInt = Integer.parseInt(ipProtocolAsString); return IpProtocol.fromNumber(ipProtocolAsInt); } catch (NumberFormatException e) { throw new BatfishException( "Could not convert AWS IP protocol: \"" + ipProtocolAsString + "\" to batfish Ip Protocol", e); } } } private  Utils(); @Nullable static IpProtocol toIpProtocol(String ipProtocolAsString); static TraceElement getTraceElementForRule(@Nullable String ruleDescription); static TraceElement getTraceElementForSecurityGroup(String securityGroupName);  }