/** * 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 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. }