/** * Sets the name of the first party of the given type. * * @return {@code true} if the name has been set, or {@code false} otherwise. */ private boolean setName(final Class<? extends AbstractParty> type, final boolean position, final InternationalString name) { checkWritePermission(); final Iterator<AbstractParty> it = getParties().iterator(); while (it.hasNext()) { final AbstractParty party = it.next(); if (type.isInstance(party)) { if (position) { ((DefaultIndividual) party).setPositionName(name); } else { party.setName(name); } if (party.isEmpty()) { it.remove(); } return true; } } return name == null; // If no party and name is null, there is nothing to set. }
/** * Sets the address of the responsible party. * * <p>This implementation sets the contact info in the first party found in the collection of * {@linkplain #getParties() parties}.</p> * * @param newValue the new contact info, or {@code null} if none. * * @deprecated As of ISO 19115:2014, replaced by {@link AbstractParty#setContactInfo(Collection)}. */ @Deprecated public void setContactInfo(final Contact newValue) { checkWritePermission(); final Iterator<AbstractParty> it = getParties().iterator(); while (it.hasNext()) { final AbstractParty party = it.next(); party.setContactInfo(newValue != null ? Collections.singleton(newValue) : null); if (party.isEmpty()) { it.remove(); } return; } /* * If no existing AbstractParty were found, add a new one. However there is no way to know if * it should be an individual or an organization. Arbitrarily choose an individual for now. */ if (newValue != null) { getParties().add(new DefaultIndividual(null, null, newValue)); } }
/** * Sets the name of the first party of the given type. * * @return {@code true} if the name has been set, or {@code false} otherwise. */ private boolean setName(final Class<? extends AbstractParty> type, final boolean position, final InternationalString name) { checkWritePermission(valueIfDefined(super.getParties())); final Iterator<AbstractParty> it = getParties().iterator(); while (it.hasNext()) { final AbstractParty party = it.next(); if (type.isInstance(party)) { if (position) { ((DefaultIndividual) party).setPositionName(name); } else { party.setName(name); } if (party.isEmpty()) { it.remove(); } return true; } } return name == null; // If no party and name is null, there is nothing to set. }
/** * Sets the address of the responsible party. * * <p>This implementation sets the contact info in the first party found in the collection of * {@linkplain #getParties() parties}.</p> * * @param newValue the new contact info, or {@code null} if none. * * @deprecated As of ISO 19115:2014, replaced by {@link AbstractParty#setContactInfo(Collection)}. */ @Deprecated public void setContactInfo(final Contact newValue) { checkWritePermission(valueIfDefined(super.getParties())); final Iterator<AbstractParty> it = getParties().iterator(); while (it.hasNext()) { final AbstractParty party = it.next(); party.setContactInfo(newValue != null ? Collections.singleton(newValue) : null); if (party.isEmpty()) { it.remove(); } return; } /* * If no existing AbstractParty were found, add a new one. However there is no way to know if * it should be an individual or an organization. Arbitrarily choose an individual for now. */ if (newValue != null) { getParties().add(new DefaultIndividual(null, null, newValue)); } }