@@ -36,6 +36,7 @@ public final class CelExtensions {
3636 private static final CelRegexExtensions REGEX_EXTENSIONS = new CelRegexExtensions ();
3737 private static final CelComprehensionsExtensions COMPREHENSIONS_EXTENSIONS =
3838 new CelComprehensionsExtensions ();
39+ private static final CelNetworkExtensions NETWORK_EXTENSIONS = new CelNetworkExtensions ();
3940
4041 /**
4142 * Implementation of optional values.
@@ -319,6 +320,18 @@ public static CelComprehensionsExtensions comprehensions() {
319320 return COMPREHENSIONS_EXTENSIONS ;
320321 }
321322
323+ /**
324+ * Extended functions for Network manipulation.
325+ *
326+ * <p>Refer to README.md for available functions.
327+ *
328+ * <p>This will include all functions denoted in {@link CelNetworkExtensions.Function}, including
329+ * any future additions.
330+ */
331+ public static CelNetworkExtensions network () {
332+ return NETWORK_EXTENSIONS ;
333+ }
334+
322335 /**
323336 * Retrieves all function names used by every extension libraries.
324337 *
@@ -339,38 +352,30 @@ public static ImmutableSet<String> getAllFunctionNames() {
339352 .map (CelListsExtensions .Function ::getFunction ),
340353 stream (CelRegexExtensions .Function .values ())
341354 .map (CelRegexExtensions .Function ::getFunction ),
355+ stream (CelNetworkExtensions .Function .values ())
356+ .map (CelNetworkExtensions .Function ::getFunction ),
342357 stream (CelComprehensionsExtensions .Function .values ())
343358 .map (CelComprehensionsExtensions .Function ::getFunction ))
344359 .collect (toImmutableSet ());
345360 }
346361
347362 public static CelExtensionLibrary <? extends CelExtensionLibrary .FeatureSet > getExtensionLibrary (
348363 String name , CelOptions options ) {
349- switch (name ) {
350- case "bindings" :
351- return CelBindingsExtensions .library ();
352- case "encoders" :
353- return CelEncoderExtensions .library (options );
354- case "lists" :
355- return CelListsExtensions .library ();
356- case "math" :
357- return CelMathExtensions .library (options );
358- case "optional" :
359- return CelOptionalLibrary .library ();
360- case "protos" :
361- return CelProtoExtensions .library ();
362- case "regex" :
363- return CelRegexExtensions .library ();
364- case "sets" :
365- return CelSetsExtensions .library (options );
366- case "strings" :
367- return CelStringExtensions .library ();
368- case "comprehensions" :
369- return CelComprehensionsExtensions .library ();
364+ return switch (name ) {
365+ case "bindings" -> CelBindingsExtensions .library ();
366+ case "encoders" -> CelEncoderExtensions .library (options );
367+ case "lists" -> CelListsExtensions .library ();
368+ case "math" -> CelMathExtensions .library (options );
369+ case "network" -> CelNetworkExtensions .library ();
370+ case "optional" -> CelOptionalLibrary .library ();
371+ case "protos" -> CelProtoExtensions .library ();
372+ case "regex" -> CelRegexExtensions .library ();
373+ case "sets" -> CelSetsExtensions .library (options );
374+ case "strings" -> CelStringExtensions .library ();
375+ case "comprehensions" -> CelComprehensionsExtensions .library ();
370376 // TODO: add support for remaining standard extensions
371- default :
372- throw new IllegalArgumentException ("Unknown standard extension '" + name + "'" );
373- }
377+ default -> throw new IllegalArgumentException ("Unknown standard extension '" + name + "'" );
378+ };
374379 }
375380
376381 private CelExtensions () {}
0 commit comments