/** * Make an instance of Map.Entry with the specified key and value. * Subclasses should override this method to return a Map.Entry * of the type being tested. */ public Map.Entry makeMapEntry(Object key, Object value) { return new UnmodifiableMapEntry(key, value); }
/** * Make an instance of Map.Entry with the default (null) key and value. * Subclasses should override this method to return a Map.Entry * of the type being tested. */ public Map.Entry makeMapEntry() { return new UnmodifiableMapEntry(null, null); }
/** * Gets the data value for the lastReturnedNode field. * @return the data value */ protected Object doGetData() { switch (dataType) { case KEY: return lastReturnedNode.getKey(); case VALUE: return lastReturnedNode.getValue(); case MAPENTRY: return lastReturnedNode; case INVERSEMAPENTRY: return new UnmodifiableMapEntry(lastReturnedNode.getValue(), lastReturnedNode.getKey()); } return null; }
/** * Gets the data value for the lastReturnedNode field. * @return the data value */ protected Object doGetData() { switch (dataType) { case KEY: return lastReturnedNode.getKey(); case VALUE: return lastReturnedNode.getValue(); case MAPENTRY: return lastReturnedNode; case INVERSEMAPENTRY: return new UnmodifiableMapEntry(lastReturnedNode.getValue(), lastReturnedNode.getKey()); } return null; }
/** * Subclasses should override this method. * */ public void testConstructors() { // 1. test key-value constructor Map.Entry entry = new UnmodifiableMapEntry(key, value); assertSame(key, entry.getKey()); assertSame(value, entry.getValue()); // 2. test pair constructor KeyValue pair = new DefaultKeyValue(key, value); entry = new UnmodifiableMapEntry(pair); assertSame(key, entry.getKey()); assertSame(value, entry.getValue()); // 3. test copy constructor Map.Entry entry2 = new UnmodifiableMapEntry(entry); assertSame(key, entry2.getKey()); assertSame(value, entry2.getValue()); assertTrue(entry instanceof Unmodifiable); }
/** * Gets the data value for the lastReturnedNode field. * @return the data value */ protected Object doGetData() { switch (dataType) { case KEY: return lastReturnedNode.getKey(); case VALUE: return lastReturnedNode.getValue(); case MAPENTRY: return lastReturnedNode; case INVERSEMAPENTRY: return new UnmodifiableMapEntry(lastReturnedNode.getValue(), lastReturnedNode.getKey()); } return null; }
/** * Gets the data value for the lastReturnedNode field. * @return the data value */ protected Object doGetData() { switch (dataType) { case KEY: return lastReturnedNode.getKey(); case VALUE: return lastReturnedNode.getValue(); case MAPENTRY: return lastReturnedNode; case INVERSEMAPENTRY: return new UnmodifiableMapEntry(lastReturnedNode.getValue(), lastReturnedNode.getKey()); } return null; }
/** * Gets the data value for the lastReturnedNode field. * @return the data value */ protected Object doGetData() { switch (dataType) { case KEY: return lastReturnedNode.getKey(); case VALUE: return lastReturnedNode.getValue(); case MAPENTRY: return lastReturnedNode; case INVERSEMAPENTRY: return new UnmodifiableMapEntry(lastReturnedNode.getValue(), lastReturnedNode.getKey()); } return null; }
/** * Gets the data value for the lastReturnedNode field. * @return the data value */ protected Object doGetData() { switch (dataType) { case KEY: return lastReturnedNode.getKey(); case VALUE: return lastReturnedNode.getValue(); case MAPENTRY: return lastReturnedNode; case INVERSEMAPENTRY: return new UnmodifiableMapEntry(lastReturnedNode.getValue(), lastReturnedNode.getKey()); } return null; }
/** * Gets the data value for the lastReturnedNode field. * @return the data value */ protected Object doGetData() { switch (dataType) { case KEY: return lastReturnedNode.getKey(); case VALUE: return lastReturnedNode.getValue(); case MAPENTRY: return lastReturnedNode; case INVERSEMAPENTRY: return new UnmodifiableMapEntry(lastReturnedNode.getValue(), lastReturnedNode.getKey()); } return null; }