public int insert(Route route) { if (queryByName(route.getName()) != null) { throw new RuntimeException("Object already exists"); } route.setId(id.getAndIncrement()); fakeDb.put(route.getId(), route); return route.getId(); }