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;
11 * Holder and factory for upgradable root modifications.
14 * This class is factory for upgradable root modifications and provides an access to set latest backing implementation.
16 final class LatestOperationHolder {
18 private ModificationApplyOperation current = AlwaysFailOperation.INSTANCE;
21 * Return latest backing implementation.
23 * @return latest backing implementation
25 ModificationApplyOperation getCurrent() {
30 * Sets latest backing implementation of associated {@link RootApplyStrategy}.
33 * Note: This does not result in upgrading implementation of already existing
34 * {@link RootApplyStrategy}. Users, who obtained instances using {@link #newSnapshot()}, deriving
35 * {@link RootApplyStrategy} from this modification must explicitly invoke
36 * {@link RootApplyStrategy#upgradeIfPossible()} on their instance to be updated to latest backing
39 * @param newApplyOper New backing implementation
41 void setCurrent(final ModificationApplyOperation newApplyOper) {
42 current = newApplyOper;
46 * Creates new upgradable {@link RootApplyStrategy} associated with holder.
48 * @return New upgradable {@link RootApplyStrategy} with {@link #getCurrent()} used
49 * as the backing implementation.
51 RootApplyStrategy newSnapshot() {
52 return new UpgradableRootApplyStrategy(this, current);