Class BindingSet<T>
- java.lang.Object
-
- com.yahoo.jdisc.application.BindingSet<T>
-
- All Implemented Interfaces:
Iterable<Map.Entry<UriPattern,T>>
public class BindingSet<T> extends Object implements Iterable<Map.Entry<UriPattern,T>>
This is an immutable set of ordered bindings from
UriPattern
s to some target type T. To create an instance of this class, you must 1) create aBindingRepository
, 2) configure it using theBindingRepository.bind(String, Object)
method, and finally 3) callBindingRepository.activate()
.- Author:
- Simon Thoresen Hult
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<Map.Entry<UriPattern,T>>
iterator()
BindingMatch<T>
match(URI uri)
Resolves the binding that best matches (see commentary onBindingRepository.bind(String, Object)
) the givenURI
, and returns aBindingMatch
object that describes the match and contains the matched target.T
resolve(URI uri)
Resolves the binding that best matches (see commentary onBindingRepository.bind(String, Object)
) the givenURI
, and returns that target.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
DEFAULT
public static final String DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
match
public BindingMatch<T> match(URI uri)
Resolves the binding that best matches (see commentary on
BindingRepository.bind(String, Object)
) the givenURI
, and returns aBindingMatch
object that describes the match and contains the matched target. If there is no binding that matches the given URI, this method returns null.- Parameters:
uri
- The URI to match against the bindings in this set.- Returns:
- A
BindingMatch
object describing the match found, or null if not found.
-
resolve
public T resolve(URI uri)
Resolves the binding that best matches (see commentary on
BindingRepository.bind(String, Object)
) the givenURI
, and returns that target. If there is no binding that matches the given URI, this method returns null.Apart from a null-guard, this is equal to
return match(uri).target()
.- Parameters:
uri
- The URI to match against the bindings in this set.- Returns:
- The best matched target, or null.
- See Also:
match(URI)
-
-