InterestTable { public void add(Interest interest, V value) { if (null == interest) { throw new NullPointerException("InterestTable may not contain null Interest"); } if (null == interest.name()) { throw new NullPointerException("InterestTable may not contain Interest with null name"); } if (Log.isLoggable(Log.FAC_ENCODING, Level.FINEST)) Log.finest(Log.FAC_ENCODING, "adding interest {0}", interest); Holder<V> holder = new InterestHolder<V>(interest, value); add(holder); }  void setCapacity(int capacity); Integer getCapacity(); void add(Interest interest, V value); void add(ContentName name, V value); Entry<V> remove(ContentName name, V value); Entry<V> remove(Interest interest, V value); V getValue(ContentObject target); Entry<V> getMatch(ContentObject target); List<V> getValues(ContentObject target); List<Entry<V>> getMatches(ContentObject target); V getValue(ContentName target); Entry<V> getMatch(ContentName target); List<V> getValues(ContentName target); List<Entry<V>> getMatches(ContentName target); Collection<Entry<V>> values(); V removeValue(ContentObject target); Entry<V> removeMatch(ContentObject target); List<V> removeValues(ContentObject target); List<Entry<V>> removeMatches(ContentObject target); int size(); int sizeNames(); void clear();  }
@Test public void testAdd() throws MalformedContentNameStringException { Log.info(Log.FAC_TEST, "Starting testAdd"); Interest intA = new Interest("/a/b/c"); Interest intB = new Interest("/a/b/c"); Interest intC = new Interest("/a/b/c/d"); ContentName namA = ContentName.fromNative("/a/b/c"); ContentName namB = ContentName.fromNative("/a/b/c"); ContentName namC = ContentName.fromNative("/a/b/c/d"); InterestTable<Object> interests = new InterestTable<Object>(); interests.add(intA, null); interests.add(intB, null); interests.add(intC, null); interests.add(intA, null); try { interests.add((Interest)null, null); fail(); } catch (NullPointerException ex) { } assertEquals(4, interests.size()); assertEquals(2, interests.sizeNames()); InterestTable<Object> names = new InterestTable<Object>(); names.add(namA, null); names.add(namB, null); names.add(namC, null); names.add(namA, null); try { names.add((ContentName)null, null); fail(); } catch (NullPointerException ex) { } assertEquals(4, names.size()); assertEquals(2, names.sizeNames()); Log.info(Log.FAC_TEST, "Completed testAdd"); }