protected static final List<Entry> copy (final List<Entry> entries) {
        if (entries == null) return null;
        final ArrayList<Entry> copy = new ArrayList<>();
        for (Entry e : entries)
            copy.add(e.copy());
        return copy;
    }

    /**
     * The abstract constructor.
     * <p>
     * Calls {@link #initializeEntries()}.
     */
    public SettingsNegotiator () {
        initializeEntries();
    }

    /**
     * Stores an exact copy of {@link #entries} in {@link #backUpEntries}.
     */
    protected final void backUpEntries () {
        backUpEntries = copy(entries);
    }

    /**
     * This method must be called at the end of a parameter negotiation task, either to roll back any changes that must
     * not take effect, or in order to ensure that consecutive negotiations are carried out correctly.
     * 
     * @param commitChanges <code>true</code> if and only if the negotiated changes to the elements in {@link #entries}
     *            are to be remembered.
     */
    protected final void commitOrRollBackChanges (final boolean commitChanges) {
        if (commitChanges)
            for (Entry e : entries)
                // allow renegotiation where allowed
                e.resetAlreadyNegotiated();
        else
            entries = backUpEntries;// roll back
        backUpEntries = null;// won't be needed anymore
    }

    /**
     * Adds a properly initialized {@link Entry} object to {@link #entries} for every parameter managed by this
     * {@link SettingsNegotiator}.
     */
    protected abstract void initializeEntries ();

    /**
     * Checks constraints that cannot be checked at the {@link Entry} level, e.g. because they depend on the values of
     * multiple parameters.
     * 
     * @return <code>true</code> if everything is fine, <code>false</code> if that is not the case
     */
    public abstract boolean checkConstraints ();
}
protected static final List < Entry > copy ( final List < Entry > entries ) { if ( entries == null ) return null ; final ArrayList < Entry > copy = new ArrayList < > ( ) ; for ( Entry e : entries ) copy . add ( e . copy ( ) ) ; return copy ; } public SettingsNegotiator ( ) { initializeEntries ( ) ; } protected final void backUpEntries ( ) { backUpEntries = copy ( entries ) ; } protected final void commitOrRollBackChanges ( final boolean commitChanges ) { if ( commitChanges ) for ( Entry e : entries ) e . resetAlreadyNegotiated ( ) ; else entries = backUpEntries ; backUpEntries = null ; } protected abstract void initializeEntries ( ) ; public abstract boolean checkConstraints ( ) ; }
Returns a deep copy of the passed {@link List} with exact copies of all contained {@link Entry} objects.

@param entries the {@link List} to copy
@return a copy of <i>entries</i>