2 * Copyright (c) 2015 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.jaxen;
10 import com.google.common.base.Function;
11 import com.google.common.base.Preconditions;
12 import javax.annotation.Nonnull;
13 import javax.annotation.Nullable;
14 import org.jaxen.Context;
15 import org.jaxen.ContextSupport;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19 * Context wrapper around a {@link NormalizedNode} for use with Jaxen. It tracks the parent node for purposes of
20 * traversing upwards the NormalizedNode tree.
22 final class NormalizedNodeContext extends Context implements Function<NormalizedNode<?, ?>, NormalizedNodeContext> {
23 private static final long serialVersionUID = 1L;
24 private final NormalizedNodeContext parent;
25 private final NormalizedNode<?, ?> node;
27 NormalizedNodeContext(@Nonnull final ContextSupport contextSupport, @Nonnull final NormalizedNode<?, ?> node,
28 @Nullable final NormalizedNodeContext parent) {
29 super(contextSupport);
30 this.node = Preconditions.checkNotNull(node);
34 @Nullable NormalizedNodeContext getParent() {
38 @Nonnull NormalizedNode<?, ?> getNode() {
43 public NormalizedNodeContext apply(final NormalizedNode<?, ?> input) {
44 return new NormalizedNodeContext(getContextSupport(), input, this);