001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2014-2015 ForgeRock AS.
015 */
016package org.opends.server.backends.pluggable.spi;
017
018import org.forgerock.opendj.ldap.ByteSequence;
019
020/**
021 * Function that computes the new value of a record for a Read-Modify-Write operation inside a transaction.
022 */
023// @FunctionalInterface
024public interface UpdateFunction {
025    /**
026     * Computes the new value for a record based on the record's existing
027     * content.
028     *
029     * @param oldValue
030     *            The record's existing content, or {@code null} if the record
031     *            does not exist at the moment and is about to be created.
032     * @return The new value for the record (which may be {@code null} if the record should be removed),
033     *         or the old value if no update is required.
034     */
035    ByteSequence computeNewValue(ByteSequence oldValue);
036}