@Test public void testRemoveNonExistingEntity() { assertNull( cache.remove( new Simple( 1 ) ) ); }
public Object remove(Object entity) { if ( entity == null ) { throw new NullPointerException( "null entities are not supported by " + getClass().getName() ); } Boolean oldOperatedOn = entityToOperatedOnFlagMap.remove( entity ); Object oldCopy = entityToCopyMap.remove( entity ); Object oldEntity = oldCopy != null ? copyToEntityMap.remove( oldCopy ) : null; if ( oldCopy == null ) { if ( oldOperatedOn != null ) { throw new IllegalStateException( "Removed entity " + printEntity( entity ) + " from EventCache#entityToOperatedOnFlagMap, but EventCache#entityToCopyMap did not contain the entity." ); } } else { if ( oldEntity == null ) { throw new IllegalStateException( "Removed entity " + printEntity( entity ) + " from EventCache#entityToCopyMap, but EventCache#copyToEntityMap did not contain the entity." ); } if ( oldOperatedOn == null ) { throw new IllegalStateException( "EventCache#entityToCopyMap contained an entity " + printEntity( entity ) + ", but EventCache#entityToOperatedOnFlagMap did not." ); } if ( oldEntity != entity ) { throw new IllegalStateException( "An entity copy " + printEntity( oldCopy ) + " was associated with a different entity " + printEntity( oldEntity ) + " than provided " + printEntity( entity ) + "." ); } } return oldCopy; }
EventCache implements Map { public Object remove(Object entity) { if ( entity == null ) { throw new NullPointerException( "null entities are not supported by " + getClass().getName() ); } Boolean oldOperatedOn = entityToOperatedOnFlagMap.remove( entity ); Object oldCopy = entityToCopyMap.remove( entity ); Object oldEntity = oldCopy != null ? copyToEntityMap.remove( oldCopy ) : null; if ( oldCopy == null ) { if ( oldOperatedOn != null ) { throw new IllegalStateException( "Removed entity " + printEntity( entity ) + " from EventCache#entityToOperatedOnFlagMap, but EventCache#entityToCopyMap did not contain the entity." ); } } else { if ( oldEntity == null ) { throw new IllegalStateException( "Removed entity " + printEntity( entity ) + " from EventCache#entityToCopyMap, but EventCache#copyToEntityMap did not contain the entity." ); } if ( oldOperatedOn == null ) { throw new IllegalStateException( "EventCache#entityToCopyMap contained an entity " + printEntity( entity ) + ", but EventCache#entityToOperatedOnFlagMap did not." ); } if ( oldEntity != entity ) { throw new IllegalStateException( "An entity copy " + printEntity( oldCopy ) + " was associated with a different entity " + printEntity( oldEntity ) + " than provided " + printEntity( entity ) + "." ); } } return oldCopy; } }
EventCache implements Map { public Object remove(Object entity) { if ( entity == null ) { throw new NullPointerException( "null entities are not supported by " + getClass().getName() ); } Boolean oldOperatedOn = entityToOperatedOnFlagMap.remove( entity ); Object oldCopy = entityToCopyMap.remove( entity ); Object oldEntity = oldCopy != null ? copyToEntityMap.remove( oldCopy ) : null; if ( oldCopy == null ) { if ( oldOperatedOn != null ) { throw new IllegalStateException( "Removed entity " + printEntity( entity ) + " from EventCache#entityToOperatedOnFlagMap, but EventCache#entityToCopyMap did not contain the entity." ); } } else { if ( oldEntity == null ) { throw new IllegalStateException( "Removed entity " + printEntity( entity ) + " from EventCache#entityToCopyMap, but EventCache#copyToEntityMap did not contain the entity." ); } if ( oldOperatedOn == null ) { throw new IllegalStateException( "EventCache#entityToCopyMap contained an entity " + printEntity( entity ) + ", but EventCache#entityToOperatedOnFlagMap did not." ); } if ( oldEntity != entity ) { throw new IllegalStateException( "An entity copy " + printEntity( oldCopy ) + " was associated with a different entity " + printEntity( oldEntity ) + " than provided " + printEntity( entity ) + "." ); } } return oldCopy; } EventCache(EventSource session); }
EventCache implements Map { public Object remove(Object entity) { if ( entity == null ) { throw new NullPointerException( "null entities are not supported by " + getClass().getName() ); } Boolean oldOperatedOn = entityToOperatedOnFlagMap.remove( entity ); Object oldCopy = entityToCopyMap.remove( entity ); Object oldEntity = oldCopy != null ? copyToEntityMap.remove( oldCopy ) : null; if ( oldCopy == null ) { if ( oldOperatedOn != null ) { throw new IllegalStateException( "Removed entity " + printEntity( entity ) + " from EventCache#entityToOperatedOnFlagMap, but EventCache#entityToCopyMap did not contain the entity." ); } } else { if ( oldEntity == null ) { throw new IllegalStateException( "Removed entity " + printEntity( entity ) + " from EventCache#entityToCopyMap, but EventCache#copyToEntityMap did not contain the entity." ); } if ( oldOperatedOn == null ) { throw new IllegalStateException( "EventCache#entityToCopyMap contained an entity " + printEntity( entity ) + ", but EventCache#entityToOperatedOnFlagMap did not." ); } if ( oldEntity != entity ) { throw new IllegalStateException( "An entity copy " + printEntity( oldCopy ) + " was associated with a different entity " + printEntity( oldEntity ) + " than provided " + printEntity( entity ) + "." ); } } return oldCopy; } EventCache(EventSource session); void clear(); boolean containsKey(Object entity); boolean containsValue(Object copy); Set entrySet(); Object get(Object entity); boolean isEmpty(); Set keySet(); Object put(Object entity, Object copy); void putAll(Map map); Object remove(Object entity); int size(); Collection values(); boolean isOperatedOn(Object entity); Map invertMap(); }
EventCache implements Map { public Object remove(Object entity) { if ( entity == null ) { throw new NullPointerException( "null entities are not supported by " + getClass().getName() ); } Boolean oldOperatedOn = entityToOperatedOnFlagMap.remove( entity ); Object oldCopy = entityToCopyMap.remove( entity ); Object oldEntity = oldCopy != null ? copyToEntityMap.remove( oldCopy ) : null; if ( oldCopy == null ) { if ( oldOperatedOn != null ) { throw new IllegalStateException( "Removed entity " + printEntity( entity ) + " from EventCache#entityToOperatedOnFlagMap, but EventCache#entityToCopyMap did not contain the entity." ); } } else { if ( oldEntity == null ) { throw new IllegalStateException( "Removed entity " + printEntity( entity ) + " from EventCache#entityToCopyMap, but EventCache#copyToEntityMap did not contain the entity." ); } if ( oldOperatedOn == null ) { throw new IllegalStateException( "EventCache#entityToCopyMap contained an entity " + printEntity( entity ) + ", but EventCache#entityToOperatedOnFlagMap did not." ); } if ( oldEntity != entity ) { throw new IllegalStateException( "An entity copy " + printEntity( oldCopy ) + " was associated with a different entity " + printEntity( oldEntity ) + " than provided " + printEntity( entity ) + "." ); } } return oldCopy; } EventCache(EventSource session); void clear(); boolean containsKey(Object entity); boolean containsValue(Object copy); Set entrySet(); Object get(Object entity); boolean isEmpty(); Set keySet(); Object put(Object entity, Object copy); void putAll(Map map); Object remove(Object entity); int size(); Collection values(); boolean isOperatedOn(Object entity); Map invertMap();  }