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
13 * This class is factory for upgradable root modifications and provides an
14 * access to set latest backing implementation.
16 final class LatestOperationHolder {
18 private ModificationApplyOperation current = AlwaysFailOperation.INSTANCE;
21 * Return latest backing implemenation
25 ModificationApplyOperation getCurrent() {
30 * Sets latest backing implementation of associated
31 * {@link RootModificationApplyOperation}.
33 * Note: This does not result in upgrading implementation of already
34 * existing {@link RootModificationApplyOperation}. Users, which
35 * obtained instances using {@link #newSnapshot()}, deriving
36 * {@link RootModificationApplyOperation} from this modification must
38 * {@link RootModificationApplyOperation#upgradeIfPossible()} on their
39 * instance to be updated to latest backing implementation.
42 * New backing implementation
44 void setCurrent(final ModificationApplyOperation newApplyOper) {
45 current = newApplyOper;
50 * Creates new upgradable {@link RootModificationApplyOperation}
51 * associated with holder.
53 * @return New upgradable {@link RootModificationApplyOperation} with
54 * {@link #getCurrent()} used as backing implementation.
56 RootModificationApplyOperation newSnapshot() {
57 return new UpgradableModificationApplyOperation(this, current);