2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
10 import static java.util.Objects.requireNonNull;
13 * Holder and factory for upgradable root modifications.
16 * This class is factory for upgradable root modifications and provides an access to set latest backing implementation.
18 final class LatestOperationHolder {
20 private ModificationApplyOperation current;
23 * Return latest backing implementation.
25 * @return latest backing implementation
27 ModificationApplyOperation getCurrent() {
32 * Sets latest backing implementation of associated {@link RootApplyStrategy}.
35 * Note: This does not result in upgrading implementation of already existing
36 * {@link RootApplyStrategy}. Users, who obtained instances using {@link #newSnapshot()}, deriving
37 * {@link RootApplyStrategy} from this modification must explicitly invoke
38 * {@link RootApplyStrategy#upgradeIfPossible()} on their instance to be updated to latest backing
41 * @param newApplyOper New backing implementation
43 void setCurrent(final ModificationApplyOperation newApplyOper) {
44 current = requireNonNull(newApplyOper);
48 * Creates new upgradable {@link RootApplyStrategy} associated with holder.
50 * @return New upgradable {@link RootApplyStrategy} with {@link #getCurrent()} used
51 * as the backing implementation.
53 RootApplyStrategy newSnapshot() {
54 return new UpgradableRootApplyStrategy(this, current);