001/* 002 * Copyright 2002-2014 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.core.type.filter; 018 019import java.io.IOException; 020 021import org.springframework.core.type.ClassMetadata; 022import org.springframework.core.type.classreading.MetadataReader; 023import org.springframework.core.type.classreading.MetadataReaderFactory; 024 025/** 026 * Type filter that exposes a 027 * {@link org.springframework.core.type.ClassMetadata} object 028 * to subclasses, for class testing purposes. 029 * 030 * @author Rod Johnson 031 * @author Costin Leau 032 * @author Juergen Hoeller 033 * @since 2.5 034 * @see #match(org.springframework.core.type.ClassMetadata) 035 */ 036public abstract class AbstractClassTestingTypeFilter implements TypeFilter { 037 038 @Override 039 public final boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) 040 throws IOException { 041 042 return match(metadataReader.getClassMetadata()); 043 } 044 045 /** 046 * Determine a match based on the given ClassMetadata object. 047 * @param metadata the ClassMetadata object 048 * @return whether this filter matches on the specified type 049 */ 050 protected abstract boolean match(ClassMetadata metadata); 051 052}