1919import java .time .Duration ;
2020import java .util .ArrayList ;
2121import java .util .Arrays ;
22+ import java .util .Collection ;
2223import java .util .Collections ;
2324import java .util .LinkedHashMap ;
2425import java .util .LinkedHashSet ;
5960 * {@link Policy} support JSON serialization and deserialization using Jackson.
6061 *
6162 * @author Mark Paluch
62- * @since 2.0
6363 * @see Rule
6464 * @see com.fasterxml.jackson.databind.ObjectMapper
65+ * @since 2.0
6566 */
6667@ JsonSerialize (using = PolicySerializer .class )
6768@ JsonDeserialize (using = PolicyDeserializer .class )
@@ -356,7 +357,7 @@ public RuleBuilder capability(Capability capability) {
356357 }
357358
358359 /**
359- * Configure capabilities. apabilities are added when calling this method and
360+ * Configure capabilities. Capabilities are added when calling this method and
360361 * do not replace already configured capabilities.
361362 * @param capabilities must not be {@literal null}.
362363 * @return {@code this} {@link RuleBuilder}.
@@ -369,6 +370,25 @@ public RuleBuilder capabilities(Capability... capabilities) {
369370 return capabilities (Arrays .asList (capabilities ));
370371 }
371372
373+ /**
374+ * Configure capabilities. Capabilities are added when calling this method and
375+ * do not replace already configured capabilities.
376+ * @param capabilities must not be {@literal null}.
377+ * @return {@code this} {@link RuleBuilder}.
378+ * @since 3.1
379+ */
380+ public RuleBuilder capabilities (Collection <? extends Capability > capabilities ) {
381+
382+ Assert .notNull (capabilities , "Capabilities must not be null" );
383+ Assert .noNullElements (capabilities , "Capabilities must not contain null elements" );
384+
385+ for (Capability capability : capabilities ) {
386+ this .capabilities .add (capability );
387+ }
388+
389+ return this ;
390+ }
391+
372392 /**
373393 * Configure capabilities represented as {@link String} literals. This method
374394 * resolves capabilities using {@link BuiltinCapabilities}. Capabilities are
@@ -397,15 +417,6 @@ public RuleBuilder capabilities(String... capabilities) {
397417 return capabilities (mapped );
398418 }
399419
400- private RuleBuilder capabilities (Iterable <Capability > capabilities ) {
401-
402- for (Capability capability : capabilities ) {
403- this .capabilities .add (capability );
404- }
405-
406- return this ;
407- }
408-
409420 /**
410421 * Configure a min TTL for response wrapping.
411422 * @param ttl must not be {@literal null}.
@@ -749,7 +760,9 @@ public JavaType getOutputType(TypeFactory typeFactory) {
749760 static class StringToDurationConverter implements Converter <String , Duration > {
750761
751762 static Pattern SECONDS = Pattern .compile ("(\\ d+)s" );
763+
752764 static Pattern MINUTES = Pattern .compile ("(\\ d+)m" );
765+
753766 static Pattern HOURS = Pattern .compile ("(\\ d+)h" );
754767
755768 @ Override
0 commit comments