PlaceRequest { public String getParameter(String key, String defaultValue) { String value = null; if (params != null) { value = params.get(key); } if (value == null) { value = defaultValue; } return value; } PlaceRequest(); private  PlaceRequest(String nameToken, Map<String, String> params); @Override boolean equals(Object obj); String getNameToken(); String getParameter(String key, String defaultValue); Set<String> getParameterNames(); @Override int hashCode(); @Override String toString(); boolean hasSameNameToken(PlaceRequest other); boolean matchesNameToken(String nameToken);  }
@Test public void builderFromPlaceRequestShouldNotShareParams() { PlaceRequest request = new PlaceRequest.Builder() .nameToken("nameToken") .with("name1", "value1") .with("name2", "value2") .build(); PlaceRequest.Builder copyBuilder = new PlaceRequest.Builder(request); copyBuilder.with("name3", "value3").build(); assertNull(request.getParameter("name3", null)); }
@Test public void builderWithoutDoesRemoveParam() { PlaceRequest request = new PlaceRequest.Builder() .nameToken("nameToken") .with("name1", "value1") .with("name2", "value2") .build(); PlaceRequest.Builder copyBuilder = new PlaceRequest.Builder(request); PlaceRequest copy = copyBuilder.without("name2").build(); assertNull(copy.getParameter("name2", null)); }