public RoomServiceImpl() { if (roomMap == null) { roomMap = new HashMap<>(); List<City> cities = new ArrayList<>(); City city = new City.Builder("Cape Town").code("8000").id("1").build(); cities.add(city); List<Residence> residences = new ArrayList<>(); Residence residence = new Residence.Builder("Plein Res").town("Cape Town").city(cities).id("1").build(); residences.add(residence); Room room = new Room.Builder("Single").residence(residences).id("1").build(); List<City> cities2 = new ArrayList<>(); City city2 = new City.Builder("Johannesburg").code("2000").id("2").build(); cities.add(city2); List<Residence> residences2 = new ArrayList<>(); Residence residence2 = new Residence.Builder("Sandton Res").town("Sandton").city(cities2).id("2").build(); residences2.add(residence); Room room2 = new Room.Builder("Double").residence(residences2).id("2").build(); roomMap.put(room.getId(), room); roomMap.put(room2.getId(), room2); } }
@Override public void remove(Room entity) { roomMap.remove(entity.getId()); }
@Override public Room merge(Room entity) { roomMap.put(entity.getId(), entity); return roomMap.get(entity.getId()); }