@SuppressWarnings("unchecked") @Override public <T> Collection<T> getAllEntitiesForType(Class<T> type) { if (packStopTimes && type.equals(StopTime.class)) { return (Collection<T>) stopTimes; } else if (packShapePoints && type.equals(ShapePoint.class)) { return (Collection<T>) shapePoints; } return super.getAllEntitiesForType(type); }
/**** * {@link GenericMutableDao} Interface ****/ @Override public <K, V> Map<K, V> getEntitiesByIdForEntityType(Class<K> keyType, Class<V> entityType) { noKeyCheck(keyType); return super.getEntitiesByIdForEntityType(keyType, entityType); }
@Override public void saveOrUpdateEntity(Object entity) { @SuppressWarnings("unchecked") IdentityBean<Serializable> bean = ((IdentityBean<Serializable>) entity); Object existing = getEntityForId(entity.getClass(), bean.getId()); // If the entity has already been inserted into storage, then we don't need // to save it if (existing == entity) return; saveEntity(entity); }
@Override public <K extends Serializable, T extends IdentityBean<K>> void removeEntity( T entity) { if (packStopTimes && entity.getClass().equals(StopTime.class)) { throw new UnsupportedOperationException(); } else if (packShapePoints && entity.getClass().equals(ShapePoint.class)) { throw new UnsupportedOperationException(); } super.removeEntity(entity); }
@Override public <T> void clearAllEntitiesForType(Class<T> type) { if (packStopTimes && type.equals(StopTime.class)) { stopTimes.clear(); return; } else if (packShapePoints && type.equals(ShapePoint.class)) { shapePoints.clear(); return; } super.clearAllEntitiesForType(type); }
@SuppressWarnings("unchecked") @Override public <T> T getEntityForId(Class<T> type, Serializable id) { if (packStopTimes && type.equals(StopTime.class)) { return (T) stopTimes.get((Integer) id); } else if (packShapePoints && type.equals(ShapePoint.class)) { return (T) shapePoints.get((Integer) id); } return super.getEntityForId(type, id); }
@Override public void close() { if (packStopTimes) { stopTimes.trimToSize(); } if (packShapePoints) { shapePoints.trimToSize(); } super.close(); }
@Override public void saveEntity(Object entity) { if (packStopTimes && entity.getClass().equals(StopTime.class)) { stopTimes.add((StopTime) entity); return; } else if (packShapePoints && entity.getClass().equals(ShapePoint.class)) { shapePoints.add((ShapePoint) entity); return; } super.saveEntity(entity); }
@SuppressWarnings("unchecked") @Override public void saveEntity(Object entity) { Class<?> c = entity.getClass(); EntityHandler<Serializable> handler = _handlers.get(c); if (handler == null) { handler = (EntityHandler<Serializable>) createEntityHandler(c); _handlers.put(c, handler); } IdentityBean<Serializable> bean = ((IdentityBean<Serializable>) entity); handler.handle(bean); Map<Object, Object> byId = _entitiesByClassAndId.get(c); if (byId == null) { byId = new HashMap<Object, Object>(); _entitiesByClassAndId.put(c, byId); } Object id = bean.getId(); Object prev = byId.put(id, entity); if (prev != null) _log.warn("entity with id already exists: class=" + c + " id=" + id + " prev=" + prev + " new=" + entity); }
@Override public <K extends Serializable, T extends IdentityBean<K>> void removeEntity( T entity) { if (packStopTimes && entity.getClass().equals(StopTime.class)) { throw new UnsupportedOperationException(); } else if (packShapePoints && entity.getClass().equals(ShapePoint.class)) { throw new UnsupportedOperationException(); } super.removeEntity(entity); }
@Override public <T> void clearAllEntitiesForType(Class<T> type) { if (packStopTimes && type.equals(StopTime.class)) { stopTimes.clear(); return; } else if (packShapePoints && type.equals(ShapePoint.class)) { shapePoints.clear(); return; } super.clearAllEntitiesForType(type); }
@SuppressWarnings("unchecked") @Override public <T> T getEntityForId(Class<T> type, Serializable id) { if (packStopTimes && type.equals(StopTime.class)) { return (T) stopTimes.get((Integer) id); } else if (packShapePoints && type.equals(ShapePoint.class)) { return (T) shapePoints.get((Integer) id); } return super.getEntityForId(type, id); }
@Override public void close() { if (packStopTimes) { stopTimes.trimToSize(); } if (packShapePoints) { shapePoints.trimToSize(); } super.close(); }
@Override public void saveEntity(Object entity) { if (packStopTimes && entity.getClass().equals(StopTime.class)) { stopTimes.add((StopTime) entity); return; } else if (packShapePoints && entity.getClass().equals(ShapePoint.class)) { shapePoints.add((ShapePoint) entity); return; } super.saveEntity(entity); }
@SuppressWarnings("unchecked") @Override public void saveEntity(Object entity) { Class<?> c = entity.getClass(); EntityHandler<Serializable> handler = _handlers.get(c); if (handler == null) { handler = (EntityHandler<Serializable>) createEntityHandler(c); _handlers.put(c, handler); } IdentityBean<Serializable> bean = ((IdentityBean<Serializable>) entity); handler.handle(bean); Map<Object, Object> byId = _entitiesByClassAndId.get(c); if (byId == null) { byId = new HashMap<Object, Object>(); _entitiesByClassAndId.put(c, byId); } Object id = bean.getId(); Object prev = byId.put(id, entity); if (prev != null) _log.warn("entity with id already exists: class=" + c + " id=" + id + " prev=" + prev + " new=" + entity); }
@Override public void saveOrUpdateEntity(Object entity) { @SuppressWarnings("unchecked") IdentityBean<Serializable> bean = ((IdentityBean<Serializable>) entity); Object existing = getEntityForId(entity.getClass(), bean.getId()); // If the entity has already been inserted into storage, then we don't need // to save it if (existing == entity) return; saveEntity(entity); }
@SuppressWarnings("unchecked") @Override public <T> Collection<T> getAllEntitiesForType(Class<T> type) { if (packStopTimes && type.equals(StopTime.class)) { return (Collection<T>) stopTimes; } else if (packShapePoints && type.equals(ShapePoint.class)) { return (Collection<T>) shapePoints; } return super.getAllEntitiesForType(type); }
/**** * {@link GenericMutableDao} Interface ****/ @Override public <K, V> Map<K, V> getEntitiesByIdForEntityType(Class<K> keyType, Class<V> entityType) { noKeyCheck(keyType); return super.getEntitiesByIdForEntityType(keyType, entityType); }