    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 *     https://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 so-called <em>references</em> stored for a
    024 * node.
    025 * </p>
    026 * <p>
    027 * Some specialized configuration implementations needs to store additional data for the nodes representing
    028 * configuration properties. This interface provides methods for querying this data. For instance, it is possible to
    029 * query a reference object stored for a specific node.
    030 * </p>
    031 * <p>
    032 * {@link InMemoryNodeModel} supports references. It can be queried for a {@code ReferenceNodeHandler} which can then be
    033 * used for dealing with references.
    034 * </p>
    035 *
    036 * @since 2.0
    037 */
    038public interface ReferenceNodeHandler extends NodeHandler<ImmutableNode> {
    039
    040    /**
    041     * Gets the reference object associated with the specified node. If no reference data is associated with this node,
    042     * result is <strong>null</strong>.
    043     *
    044     * @param node the node in question
    045     * @return the reference object for this node or <strong>null</strong>
    046     */
    047    Object getReference(ImmutableNode node);
    048
    049    /**
    050     * Returns a list with the reference objects for nodes which have been removed. Whenever a node associated with a
    051     * reference object is removed from the nodes structure managed by the owning model, the reference object is recorded.
    052     * This is necessary for instance to free some resources. With this method all recorded reference objects can be
    053     * queried. They are typically returned in the order in which they have been removed.
    054     *
    055     * @return a list with reference objects for nodes removed from the model
    056     */
    057    List<Object> removedReferences();
    058}