@Test public void testReplace() { AttributeContainerMutable attc = new AttributeContainerMutable("container"); Attribute att = new Attribute("name", "valuable"); attc.addAttribute(att); attc.addAttribute("name3", 123); assertThat(Iterables.size(attc)).isEqualTo(2); assertThat(attc.findAttribute("name2")).isNull(); assertThat(attc.replace(att, "name2")).isTrue(); assertThat(Iterables.size(attc)).isEqualTo(2); assertThat(attc.findAttribute("name2")).isNotNull(); assertThat(attc.findAttributeString("name2", null)).isEqualTo("valuable"); }
public boolean replace(Attribute a, String newName) { boolean ok = atts.remove(a); Attribute newAtt = a.toBuilder().setName(newName).build(); addAttribute(newAtt); return ok; }
AttributeContainerMutable implements AttributeContainer { public boolean replace(Attribute a, String newName) { boolean ok = atts.remove(a); Attribute newAtt = a.toBuilder().setName(newName).build(); addAttribute(newAtt); return ok; } }
AttributeContainerMutable implements AttributeContainer { public boolean replace(Attribute a, String newName) { boolean ok = atts.remove(a); Attribute newAtt = a.toBuilder().setName(newName).build(); addAttribute(newAtt); return ok; } AttributeContainerMutable(@Nullable String name);  AttributeContainerMutable(@Nullable String name, Iterable<Attribute> from); }
AttributeContainerMutable implements AttributeContainer { public boolean replace(Attribute a, String newName) { boolean ok = atts.remove(a); Attribute newAtt = a.toBuilder().setName(newName).build(); addAttribute(newAtt); return ok; } AttributeContainerMutable(@Nullable String name);  AttributeContainerMutable(@Nullable String name, Iterable<Attribute> from); static AttributeContainerMutable copyFrom(@Nullable AttributeContainer from); void setName(@Nullable String name); @Override @Nullable String getName(); @Override Iterator<Attribute> iterator(); Attribute addAttribute(Attribute att); Attribute addAttribute(String name, String value); Attribute addAttribute(String name, Number value); void addAll(Iterable<Attribute> atts); @Override String findAttributeString(String attName, String defaultValue); @Override Attribute findAttribute(String name); @Override Attribute findAttributeIgnoreCase(String name); @Override double findAttributeDouble(String attName, double defaultValue); @Override int findAttributeInteger(String attName, int defaultValue); boolean remove(Attribute a); boolean replace(Attribute a, String newName); AttributeContainerMutable clear(); boolean removeAttribute(String attName); boolean removeAttributeIgnoreCase(String attName); AttributeContainer toImmutable(); @Override boolean isEmpty(); }
AttributeContainerMutable implements AttributeContainer { public boolean replace(Attribute a, String newName) { boolean ok = atts.remove(a); Attribute newAtt = a.toBuilder().setName(newName).build(); addAttribute(newAtt); return ok; } AttributeContainerMutable(@Nullable String name);  AttributeContainerMutable(@Nullable String name, Iterable<Attribute> from); static AttributeContainerMutable copyFrom(@Nullable AttributeContainer from); void setName(@Nullable String name); @Override @Nullable String getName(); @Override Iterator<Attribute> iterator(); Attribute addAttribute(Attribute att); Attribute addAttribute(String name, String value); Attribute addAttribute(String name, Number value); void addAll(Iterable<Attribute> atts); @Override String findAttributeString(String attName, String defaultValue); @Override Attribute findAttribute(String name); @Override Attribute findAttributeIgnoreCase(String name); @Override double findAttributeDouble(String attName, double defaultValue); @Override int findAttributeInteger(String attName, int defaultValue); boolean remove(Attribute a); boolean replace(Attribute a, String newName); AttributeContainerMutable clear(); boolean removeAttribute(String attName); boolean removeAttributeIgnoreCase(String attName); AttributeContainer toImmutable(); @Override boolean isEmpty();  }