001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.configuration2.tree;
018
019import java.util.List;
020
021/**
022 * <p>
023 * An extension of the {@link NodeHandler} interface which allows access to
024 * so-called <em>references</em> stored for a node.
025 * </p>
026 * <p>
027 * Some specialized configuration implementations needs to store additional data
028 * for the nodes representing configuration properties. This interface provides
029 * methods for querying this data. For instance, it is possible to query a
030 * reference object stored for a specific node.
031 * </p>
032 * <p>
033 * {@link InMemoryNodeModel} supports references. It can be queried for a
034 * {@code ReferenceNodeHandler} which can then be used for dealing with
035 * references.
036 * </p>
037 *
038 * @since 2.0
039 */
040public interface ReferenceNodeHandler extends NodeHandler<ImmutableNode>
041{
042    /**
043     * Returns the reference object associated with the specified node. If no
044     * reference data is associated with this node, result is <b>null</b>.
045     *
046     * @param node the node in question
047     * @return the reference object for this node or <b>null</b>
048     */
049    Object getReference(ImmutableNode node);
050
051    /**
052     * Returns a list with the reference objects for nodes which have been
053     * removed. Whenever a node associated with a reference object is removed
054     * from the nodes structure managed by the owning model, the reference
055     * object is recorded. This is necessary for instance to free some
056     * resources. With this method all recorded reference objects can be
057     * queried. They are typically returned in the order in which they have been
058     * removed.
059     *
060     * @return a list with reference objects for nodes removed from the model
061     */
062    List<Object> removedReferences();
063}