/** * <p>Convenient method for calling {@link #put(UriPattern, Object)} for all entries in a collection of * bindings.</p> * * @param bindings The collection of bindings to copy to this. * @throws NullPointerException If argument is null or contains null. */ public void putAll(Iterable<Map.Entry<UriPattern, T>> bindings) { for (Map.Entry<UriPattern, T> entry : bindings) { put(entry.getKey(), entry.getValue()); } }
private void addFilter(Object filter, String binding) { if (filter instanceof RequestFilter && filter instanceof ResponseFilter) { throw new RuntimeException("The filter " + filter.getClass().getName() + " is unsupported since it's both a RequestFilter and a ResponseFilter."); } else if (filter instanceof RequestFilter) { requestFilters.put(new UriPattern(binding), (RequestFilter) filter); } else if (filter instanceof ResponseFilter) { responseFilters.put(new UriPattern(binding), (ResponseFilter) filter); } else { throw new RuntimeException("Unknown filter type " + filter.getClass().getName()); } }
/** * <p>Creates a {@link UriPattern} from the given pattern string, and calls {@link #put(UriPattern, Object)}.</p> * * @param uriPattern The URI pattern to parse and bind to the target. * @param target The target to assign to the URI pattern. * @throws NullPointerException If any argument is null. * @throws IllegalArgumentException If the URI pattern string could not be parsed. */ public void bind(String uriPattern, T target) { put(new UriPattern(uriPattern), target); }