Do not pretty-print body class
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / LatestOperationHolder.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
9
10 import static java.util.Objects.requireNonNull;
11
12 /**
13  * Holder and factory for upgradable root modifications.
14  *
15  * <p>
16  * This class is factory for upgradable root modifications and provides an access to set latest backing implementation.
17  */
18 final class LatestOperationHolder {
19
20     private ModificationApplyOperation current;
21
22     /**
23      * Return latest backing implementation.
24      *
25      * @return latest backing implementation
26      */
27     ModificationApplyOperation getCurrent() {
28         return current;
29     }
30
31     /**
32      * Sets latest backing implementation of associated {@link RootApplyStrategy}.
33      *
34      * <p>
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
39      * implementation.
40      *
41      * @param newApplyOper New backing implementation
42      */
43     void setCurrent(final ModificationApplyOperation newApplyOper) {
44         current = requireNonNull(newApplyOper);
45     }
46
47     /**
48      * Creates new upgradable {@link RootApplyStrategy} associated with holder.
49      *
50      * @return New upgradable {@link RootApplyStrategy} with {@link #getCurrent()} used
51      *         as the backing implementation.
52      */
53     RootApplyStrategy newSnapshot() {
54         return new UpgradableRootApplyStrategy(this, current);
55     }
56
57 }