From 278bfc319cc905bdf150af814bb3461896b68444 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 25 Oct 2015 13:35:25 -0400 Subject: Add version 1.3.1 site. --- .../tavianator/sangria/listbinder/ListBinder.html | 390 +++++++++++++++++++++ 1 file changed, 390 insertions(+) create mode 100644 1.3.1/apidocs/com/tavianator/sangria/listbinder/ListBinder.html (limited to '1.3.1/apidocs/com/tavianator/sangria/listbinder/ListBinder.html') diff --git a/1.3.1/apidocs/com/tavianator/sangria/listbinder/ListBinder.html b/1.3.1/apidocs/com/tavianator/sangria/listbinder/ListBinder.html new file mode 100644 index 0000000..10d8231 --- /dev/null +++ b/1.3.1/apidocs/com/tavianator/sangria/listbinder/ListBinder.html @@ -0,0 +1,390 @@ + + + + + + +ListBinder (Sangria 1.3.1 API) + + + + + + + + +
+ + + + + + + +
+ + + +
+
com.tavianator.sangria.listbinder
+

Class ListBinder<T>

+
+
+ +
+
    +
  • +
    +
    Type Parameters:
    +
    T - The type of the list element.
    +
    +
    +
    +
    public class ListBinder<T>
    +extends Object
    +
    A multi-binder with guaranteed order. + +

    + ListBinder is much like Multibinder, except it provides a guaranteed iteration order, and binds a + List instead of a Set. For example: +

    + +
    + ListBinder<String> listBinder = ListBinder.build(binder(), String.class)
    +         .withDefaultPriority();
    + listBinder.addBinding().toInstance("a");
    + listBinder.addBinding().toInstance("b");
    + 
    + +

    + This will create a binding for a List<String>, which contains "a" followed by "b". It also + creates a binding for List<Provider<String>> — this may be useful in more advanced cases to allow list + elements to be lazily loaded. +

    + +

    To add an annotation to the list binding, simply write this:

    + +
    + ListBinder<String> listBinder = ListBinder.build(binder(), String.class)
    +         .annotatedWith(Names.named("name"))
    +         .withDefaultPriority();
    + 
    + +

    + and the created binding will be @Named("name") List<String> instead. +

    + +

    + For large lists, it may be helpful to split up their specification across different modules. This is accomplished by + specifying priorities for the ListBinders when they are created. For example: +

    + +
    + // In some module
    + ListBinder<String> listBinder1 = ListBinder.build(binder(), String.class)
    +         .withPriority(0);
    + listBinder1.addBinding().toInstance("a");
    + listBinder1.addBinding().toInstance("b");
    +
    + // ... some other module
    + ListBinder<String> listBinder2 = ListBinder.build(binder(), String.class)
    +         .withPriority(1);
    + listBinder2.addBinding().toInstance("c");
    + listBinder2.addBinding().toInstance("d");
    + 
    + +

    + The generated list will contain "a", "b", "c", "d", in order. This happens because + the first ListBinder had a smaller priority, so its entries come first. For more information about the + priority system, see Priority. +

    +
    +
    Since:
    +
    1.1
    +
    Version:
    +
    1.1
    +
    Author:
    +
    Tavian Barnes (tavianator@tavianator.com)
    +
    +
  • +
+
+
+ +
+
+ +
+
+ + +
+ + + + + + + +
+ + +

Copyright © 2014–2015. All rights reserved.

+ + -- cgit v1.2.3