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