/** * Adds a new telephone number. As a special case if the first element is empty, then the telephone number * will be set in that element. We test only the first element because {@link DefaultTelephone#getOwner()} * initialize new collections as collection containing {@code DefaultTelephone.this}. * * @param value the telephone number to add. * @return {@code true} if the element has been added. */ @Override public boolean add(final String value) { // Null value happen with empty XML elements like <gco:CharacterString/> if (value == null || value.isEmpty()) { return false; } final Iterator<Telephone> it = elements.iterator(); if (it.hasNext()) { final Telephone telephone = it.next(); if (telephone instanceof DefaultTelephone && ((DefaultTelephone) telephone).isEmpty()) { if (update(telephone, value)) { return true; } } } return elements.add(wrap(value)); } }
/** * Adds a new telephone number. As a special case if the first element is empty, then the telephone number * will be set in that element. We test only the first element because {@link DefaultTelephone#getOwner()} * initialize new collections as collection containing {@code DefaultTelephone.this}. * * @param value the telephone number to add. * @return {@code true} if the element has been added. */ @Override public boolean add(final String value) { // Null value happen with empty XML elements like <gco:CharacterString/> if (value == null || value.isEmpty()) { return false; } final Iterator<Telephone> it = elements.iterator(); if (it.hasNext()) { final Telephone telephone = it.next(); if (telephone instanceof DefaultTelephone && ((DefaultTelephone) telephone).isEmpty()) { if (update(telephone, value)) { return true; } } } return elements.add(wrap(value)); } }