/*
 * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.yangtools.yang.data.impl.schema.tree;

import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import java.util.Collections;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeTip;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;

abstract class AbstractDataTreeTip implements DataTreeTip {
    private static final YangInstanceIdentifier PUBLIC_ROOT_PATH = YangInstanceIdentifier.create(Collections.emptyList());

    /**
     * Return the current root node of this tip.
     *
     * @return Current tip root node, may not be null.
     */
    @Nonnull protected abstract TreeNode getTipRoot();

    @Override
    public final void validate(final DataTreeModification modification) throws DataValidationFailedException {
        Preconditions.checkArgument(modification instanceof InMemoryDataTreeModification, "Invalid modification class %s", modification.getClass());
        final InMemoryDataTreeModification m = (InMemoryDataTreeModification)modification;
        Preconditions.checkArgument(m.isSealed(), "Attempted to verify unsealed modification %s", m);

        m.getStrategy().checkApplicable(PUBLIC_ROOT_PATH, m.getRootModification(), Optional.of(getTipRoot()), m.getVersion());
    }

    @Override
    public final DataTreeCandidateTip prepare(final DataTreeModification modification) {
        Preconditions.checkArgument(modification instanceof InMemoryDataTreeModification, "Invalid modification class %s", modification.getClass());
        final InMemoryDataTreeModification m = (InMemoryDataTreeModification)modification;
        Preconditions.checkArgument(m.isSealed(), "Attempted to prepare unsealed modification %s", m);

        final ModifiedNode root = m.getRootModification();

        final TreeNode currentRoot = getTipRoot();
        if (root.getOperation() == LogicalOperation.NONE) {
            return new NoopDataTreeCandidate(PUBLIC_ROOT_PATH, root, currentRoot);
        }

        final Optional<TreeNode> newRoot = m.getStrategy().apply(m.getRootModification(),
            Optional.of(currentRoot), m.getVersion());
        Preconditions.checkState(newRoot.isPresent(), "Apply strategy failed to produce root node for modification %s", modification);
        return new InMemoryDataTreeCandidate(PUBLIC_ROOT_PATH, root, currentRoot, newRoot.get());
    }
}

@@ -454,38 +454,8 @@
 ns;%0A
-import java.util.Collections;%0A
 impo
@@ -1022,132 +1022,8 @@
 p %7B%0A
-    private static final YangInstanceIdentifier PUBLIC_ROOT_PATH = YangInstanceIdentifier.create(Collections.emptyList());%0A%0A
     
@@ -1407,32 +1407,44 @@
 reeModification,
+%0A           
  %22Invalid modifi
@@ -1721,32 +1721,44 @@
 licable(
-PUBLIC_ROOT_PATH
+YangInstanceIdentifier.EMPTY
 , m.getR
@@ -1775,16 +1775,28 @@
 ation(),
+%0A           
  Optiona
@@ -2031,16 +2031,28 @@
 ication,
+%0A           
  %22Invali
@@ -2514,32 +2514,44 @@
 ndidate(
-PUBLIC_ROOT_PATH
+YangInstanceIdentifier.EMPTY
 , root, 
@@ -2904,24 +2904,36 @@
 ate(
-PUBLIC_ROOT_PATH
+YangInstanceIdentifier.EMPTY
 , ro

Use YangInstanceIdentifier.EMPTY