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 019/** 020 * <p> 021 * An interface for matching nodes based on specific criteria. 022 * </p> 023 * <p> 024 * This interface is used by {@link NodeHandler} to support advanced filtering on the child nodes of a given parent 025 * node. This is useful for instance for special {@link ExpressionEngine} implementations which do no direct or strict 026 * matches based on node names. An example could be an expression engine that treats the passed in node keys in a 027 * case-insensitive manner. Such an engine would use a special case-insensitive matcher when resolving configuration 028 * keys. 029 * </p> 030 * <p> 031 * The idea behind this interface is that a matcher has to match a property of a node against a given criterion. This 032 * criterion is passed to the matching function so that matchers can be implemented in a state-less fashion and shared 033 * between multiple components. 034 * </p> 035 * 036 * @since 2.0 037 * @param <C> the type of the criterion evaluated by this matcher 038 */ 039public interface NodeMatcher<C> { 040 /** 041 * Tests whether the passed in node matches the given criterion. 042 * 043 * @param node the node to be tested 044 * @param handler the corresponding {@code NodeHandler} 045 * @param criterion the criterion to match against 046 * @param <T> the type of the node 047 * @return <b>true</b> if this node matches the criterion, <b>false</b> otherwise 048 */ 049 <T> boolean matches(T node, NodeHandler<T> handler, C criterion); 050}