001 /* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014 package org.apache.commons.classscan.model; 015 016 import java.util.Set; 017 018 import org.apache.commons.classscan.HasName; 019 import org.apache.commons.classscan.MetaClassPathElement; 020 021 /** 022 * Metadata about a class or primitive type 023 */ 024 public interface MetaClass extends HasName, MetaType { 025 /** 026 * Get the ClassLocation from which the corresponding class came. For 027 * primitive types, this will return null. 028 */ 029 MetaClassPathElement getClassLocation(); 030 031 /** 032 * Get the canonical name of the corresponding Class. For primitive types, 033 * this will be the primitive type name. e.g. char 034 */ 035 String getName(); 036 037 /** 038 * Get metadata about the corresponding Class's parent 039 * 040 * @return The MetaClass, or null if the corresponding Class is a primitive 041 * type or Object.class 042 */ 043 MetaClass getParent(); 044 045 /** 046 * Get metadata about the interfaces which the corresponding Class 047 * implements. No inherited interfaces will be in the set. 048 * 049 * @return A read-only set of the interface information 050 */ 051 Set<? extends MetaClass> getInterfaces(); 052 053 /** 054 * Get metadata about the annotations on the corresponding Class. 055 * 056 * @return A read-only set of the annotation information 057 */ 058 Set<? extends MetaAnnotation> getAnnotations(); 059 060 /** 061 * Get metadata about a particular annotation on the corresponding Class. 062 * 063 * @param annotationName 064 * The name of the annotation desired 065 * 066 * @return The annotation information, or null if not specified on the 067 * corresponding Class 068 */ 069 MetaAnnotation getAnnotation(String annotationName); 070 071 /** 072 * Get metadata about the corresponding Class's methods and constructors. No 073 * inherited methods will be in the set. 074 * 075 * @return A read-only set of the method information 076 */ 077 Set<? extends MetaMethod> getMethods(); 078 079 /** 080 * Get metadata about the corresponding Class's methods and constructors. No 081 * inherited fields will be in the set. 082 * 083 * @return A read-only set of the field information 084 */ 085 Set<? extends MetaField> getFields(); 086 087 /** 088 * Is the associated Class assignable from the class associated with the 089 * given MetaClass. 090 * 091 * @param assignor 092 * The non-null MetaClass (associated with class or interface) 093 * @return true, if and only if instances represented by implementor can be 094 * assigned to instances represented by this MetaClass 095 */ 096 boolean isAssignableFrom(MetaClass assignor); 097 }