@Override
  public boolean matches(Pair<Request, Response> requestResponse) {
    Request request = requestResponse.first();
    Response response = requestResponse.second();

    return (response.status().isSuccessful() || response.status().equals(NOT_MODIFIED))
        && isAcceptableMediaType(response)
        && !internalRequestMarker.isInternal(request);
  }
Esempio n. 2
0
 public static <K, V> TreeMap<K, V> treeMap(
     final TreeFactory factory,
     final Comparator<K> comparator,
     final List<Pair<K, V>> sortedList) {
   if (sortedList.size() == 0) return factory.create(comparator);
   int middle = sortedList.size() / 2;
   Pair<K, V> pair = sortedList.get(middle);
   TreeMap<K, V> left = treeMap(factory, comparator, sortedList.subList(0, middle));
   TreeMap<K, V> right =
       treeMap(factory, comparator, sortedList.subList(middle + 1, sortedList.size()));
   return factory.create(comparator, pair.first(), pair.second(), left, right);
 }
Esempio n. 3
0
 public static <K, V, M extends PersistentMap<K, V>> Pair<M, Option<V>> remove(M map, K key) {
   return Pair.pair(Unchecked.<M>cast(map.delete(key)), map.lookup(key));
 }
Esempio n. 4
0
 public static <K, V, M extends PersistentMap<K, V>> Pair<M, Option<V>> put(
     M map, K key, V newValue) {
   return Pair.pair(Unchecked.<M>cast(map.insert(key, newValue)), map.lookup(key));
 }