/** * Returns a new <code>Map.Entry</code> object with key and value from this pair. * * @return a MapEntry instance */ public Map.Entry toMapEntry() { return new DefaultMapEntry(this); }
/** * Recalculate the hash code after deserialization. * The hash code of some keys might have change (hash codes based * on the system hash code are only stable for the same process). * * @return the instance with recalculated hash code */ private Object readResolve() { calculateHashCode(keys); return this; } }
public void testConstructorsByArrayNull() throws Exception { Object[] keys = null; try { new MultiKey(keys); fail(); } catch (IllegalArgumentException ex) {} try { new MultiKey(keys, true); fail(); } catch (IllegalArgumentException ex) {} try { new MultiKey(keys, false); fail(); } catch (IllegalArgumentException ex) {} }
public void testAccessorsAndMutators() { DefaultKeyValue kv = makeDefaultKeyValue(); kv.setKey(key); assertTrue(kv.getKey() == key); kv.setValue(value); assertTrue(kv.getValue() == value); // check that null doesn't do anything funny kv.setKey(null); assertTrue(kv.getKey() == null); kv.setValue(null); assertTrue(kv.getValue() == null); }
public void testToString() { DefaultKeyValue kv = makeDefaultKeyValue(key, value); assertTrue(kv.toString().equals(kv.getKey() + "=" + kv.getValue())); // test with nulls kv = makeDefaultKeyValue(null, null); assertTrue(kv.toString().equals(kv.getKey() + "=" + kv.getValue())); }
/** * 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); }
/** * Make an instance of DefaultKeyValue with the specified key and value. * Subclasses should override this method to return a DefaultKeyValue * of the type being tested. */ protected DefaultKeyValue makeDefaultKeyValue(Object key, Object value) { return new DefaultKeyValue(key, value); }
public void testEqualsAndHashCode() { // 1. test with object data DefaultKeyValue kv = makeDefaultKeyValue(key, value); DefaultKeyValue kv2 = makeDefaultKeyValue(key, value); assertTrue(kv.equals(kv)); assertTrue(kv.equals(kv2)); assertTrue(kv.hashCode() == kv2.hashCode()); // 2. test with nulls kv = makeDefaultKeyValue(null, null); kv2 = makeDefaultKeyValue(null, null); assertTrue(kv.equals(kv)); assertTrue(kv.equals(kv2)); assertTrue(kv.hashCode() == kv2.hashCode()); }
/** * 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 abstract Map.Entry makeMapEntry(Object key, Object value);
/** * Makes a Map.Entry of a type that's known to work correctly. */ public Map.Entry makeKnownMapEntry() { return makeKnownMapEntry(null, null); }
/** * Returns a new <code>Map.Entry</code> object with key and value from this pair. * * @return a MapEntry instance */ public Map.Entry toMapEntry() { return new DefaultMapEntry(this); }
/** * 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); }
/** * Recalculate the hash code after deserialization. * The hash code of some keys might have change (hash codes based * on the system hash code are only stable for the same process). * * @return the instance with recalculated hash code */ private Object readResolve() { calculateHashCode(keys); return this; } }
/** * Make an instance of DefaultKeyValue with the default (null) key and value. * Subclasses should override this method to return a DefaultKeyValue * of the type being tested. */ protected DefaultKeyValue makeDefaultKeyValue() { return new DefaultKeyValue(null, null); }
/** * 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 DefaultMapEntry(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 DefaultMapEntry(null, null); }