|
23 | 23 | import java.security.MessageDigest; |
24 | 24 | import java.security.NoSuchAlgorithmException; |
25 | 25 | import java.util.Base64; |
26 | | -import java.util.HashMap; |
27 | 26 | import java.util.List; |
28 | 27 | import java.util.Locale; |
29 | 28 | import java.util.Map; |
30 | 29 | import java.util.function.Supplier; |
31 | 30 |
|
| 31 | +import static java.util.Map.entry; |
32 | 32 | import static org.elasticsearch.ingest.ConfigurationUtils.newConfigurationException; |
33 | 33 | import static org.elasticsearch.ingest.ConfigurationUtils.readBooleanProperty; |
34 | 34 |
|
@@ -416,22 +416,19 @@ public enum Type { |
416 | 416 |
|
417 | 417 | private final int transportNumber; |
418 | 418 |
|
419 | | - private static final Map<String, Type> TRANSPORT_NAMES; |
420 | | - |
421 | | - static { |
422 | | - TRANSPORT_NAMES = new HashMap<>(); |
423 | | - TRANSPORT_NAMES.put("icmp", Icmp); |
424 | | - TRANSPORT_NAMES.put("igmp", Igmp); |
425 | | - TRANSPORT_NAMES.put("tcp", Tcp); |
426 | | - TRANSPORT_NAMES.put("udp", Udp); |
427 | | - TRANSPORT_NAMES.put("gre", Gre); |
428 | | - TRANSPORT_NAMES.put("ipv6-icmp", IcmpIpV6); |
429 | | - TRANSPORT_NAMES.put("icmpv6", IcmpIpV6); |
430 | | - TRANSPORT_NAMES.put("eigrp", Eigrp); |
431 | | - TRANSPORT_NAMES.put("ospf", Ospf); |
432 | | - TRANSPORT_NAMES.put("pim", Pim); |
433 | | - TRANSPORT_NAMES.put("sctp", Sctp); |
434 | | - } |
| 419 | + private static final Map<String, Type> TRANSPORT_NAMES = Map.ofEntries( |
| 420 | + entry("icmp", Icmp), |
| 421 | + entry("igmp", Igmp), |
| 422 | + entry("tcp", Tcp), |
| 423 | + entry("udp", Udp), |
| 424 | + entry("gre", Gre), |
| 425 | + entry("ipv6-icmp", IcmpIpV6), |
| 426 | + entry("icmpv6", IcmpIpV6), |
| 427 | + entry("eigrp", Eigrp), |
| 428 | + entry("ospf", Ospf), |
| 429 | + entry("pim", Pim), |
| 430 | + entry("sctp", Sctp) |
| 431 | + ); |
435 | 432 |
|
436 | 433 | Type(int transportNumber) { |
437 | 434 | this.transportNumber = transportNumber; |
@@ -536,34 +533,31 @@ public enum IcmpType { |
536 | 533 | V6HomeAddressDiscoveryRequest(144), |
537 | 534 | V6HomeAddressDiscoveryResponse(145); |
538 | 535 |
|
539 | | - private static final Map<Integer, Integer> ICMP_V4_CODE_EQUIVALENTS; |
540 | | - private static final Map<Integer, Integer> ICMP_V6_CODE_EQUIVALENTS; |
541 | | - |
542 | | - static { |
543 | | - ICMP_V4_CODE_EQUIVALENTS = new HashMap<>(); |
544 | | - ICMP_V4_CODE_EQUIVALENTS.put(EchoRequest.getType(), EchoReply.getType()); |
545 | | - ICMP_V4_CODE_EQUIVALENTS.put(EchoReply.getType(), EchoRequest.getType()); |
546 | | - ICMP_V4_CODE_EQUIVALENTS.put(TimestampRequest.getType(), TimestampReply.getType()); |
547 | | - ICMP_V4_CODE_EQUIVALENTS.put(TimestampReply.getType(), TimestampRequest.getType()); |
548 | | - ICMP_V4_CODE_EQUIVALENTS.put(InfoRequest.getType(), InfoReply.getType()); |
549 | | - ICMP_V4_CODE_EQUIVALENTS.put(RouterSolicitation.getType(), RouterAdvertisement.getType()); |
550 | | - ICMP_V4_CODE_EQUIVALENTS.put(RouterAdvertisement.getType(), RouterSolicitation.getType()); |
551 | | - ICMP_V4_CODE_EQUIVALENTS.put(AddressMaskRequest.getType(), AddressMaskReply.getType()); |
552 | | - ICMP_V4_CODE_EQUIVALENTS.put(AddressMaskReply.getType(), AddressMaskRequest.getType()); |
553 | | - |
554 | | - ICMP_V6_CODE_EQUIVALENTS = new HashMap<>(); |
555 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6EchoRequest.getType(), V6EchoReply.getType()); |
556 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6EchoReply.getType(), V6EchoRequest.getType()); |
557 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6RouterSolicitation.getType(), V6RouterAdvertisement.getType()); |
558 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6RouterAdvertisement.getType(), V6RouterSolicitation.getType()); |
559 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6NeighborAdvertisement.getType(), V6NeighborSolicitation.getType()); |
560 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6NeighborSolicitation.getType(), V6NeighborAdvertisement.getType()); |
561 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6MLDv1MulticastListenerQueryMessage.getType(), V6MLDv1MulticastListenerReportMessage.getType()); |
562 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6WhoAreYouRequest.getType(), V6WhoAreYouReply.getType()); |
563 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6WhoAreYouReply.getType(), V6WhoAreYouRequest.getType()); |
564 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6HomeAddressDiscoveryRequest.getType(), V6HomeAddressDiscoveryResponse.getType()); |
565 | | - ICMP_V6_CODE_EQUIVALENTS.put(V6HomeAddressDiscoveryResponse.getType(), V6HomeAddressDiscoveryRequest.getType()); |
566 | | - } |
| 536 | + private static final Map<Integer, Integer> ICMP_V4_CODE_EQUIVALENTS = Map.ofEntries( |
| 537 | + entry(EchoRequest.getType(), EchoReply.getType()), |
| 538 | + entry(EchoReply.getType(), EchoRequest.getType()), |
| 539 | + entry(TimestampRequest.getType(), TimestampReply.getType()), |
| 540 | + entry(TimestampReply.getType(), TimestampRequest.getType()), |
| 541 | + entry(InfoRequest.getType(), InfoReply.getType()), |
| 542 | + entry(RouterSolicitation.getType(), RouterAdvertisement.getType()), |
| 543 | + entry(RouterAdvertisement.getType(), RouterSolicitation.getType()), |
| 544 | + entry(AddressMaskRequest.getType(), AddressMaskReply.getType()), |
| 545 | + entry(AddressMaskReply.getType(), AddressMaskRequest.getType()) |
| 546 | + ); |
| 547 | + |
| 548 | + private static final Map<Integer, Integer> ICMP_V6_CODE_EQUIVALENTS = Map.ofEntries( |
| 549 | + entry(V6EchoRequest.getType(), V6EchoReply.getType()), |
| 550 | + entry(V6EchoReply.getType(), V6EchoRequest.getType()), |
| 551 | + entry(V6RouterSolicitation.getType(), V6RouterAdvertisement.getType()), |
| 552 | + entry(V6RouterAdvertisement.getType(), V6RouterSolicitation.getType()), |
| 553 | + entry(V6NeighborAdvertisement.getType(), V6NeighborSolicitation.getType()), |
| 554 | + entry(V6NeighborSolicitation.getType(), V6NeighborAdvertisement.getType()), |
| 555 | + entry(V6MLDv1MulticastListenerQueryMessage.getType(), V6MLDv1MulticastListenerReportMessage.getType()), |
| 556 | + entry(V6WhoAreYouRequest.getType(), V6WhoAreYouReply.getType()), |
| 557 | + entry(V6WhoAreYouReply.getType(), V6WhoAreYouRequest.getType()), |
| 558 | + entry(V6HomeAddressDiscoveryRequest.getType(), V6HomeAddressDiscoveryResponse.getType()), |
| 559 | + entry(V6HomeAddressDiscoveryResponse.getType(), V6HomeAddressDiscoveryRequest.getType()) |
| 560 | + ); |
567 | 561 |
|
568 | 562 | private final int type; |
569 | 563 |
|
|
0 commit comments