001/* 002 * Copyright 2002-2017 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; 018 019import org.springframework.lang.Nullable; 020 021/** 022 * Interface that defines abstract metadata of a specific class, 023 * in a form that does not require that class to be loaded yet. 024 * 025 * @author Juergen Hoeller 026 * @since 2.5 027 * @see StandardClassMetadata 028 * @see org.springframework.core.type.classreading.MetadataReader#getClassMetadata() 029 * @see AnnotationMetadata 030 */ 031public interface ClassMetadata { 032 033 /** 034 * Return the name of the underlying class. 035 */ 036 String getClassName(); 037 038 /** 039 * Return whether the underlying class represents an interface. 040 */ 041 boolean isInterface(); 042 043 /** 044 * Return whether the underlying class represents an annotation. 045 * @since 4.1 046 */ 047 boolean isAnnotation(); 048 049 /** 050 * Return whether the underlying class is marked as abstract. 051 */ 052 boolean isAbstract(); 053 054 /** 055 * Return whether the underlying class represents a concrete class, 056 * i.e. neither an interface nor an abstract class. 057 */ 058 default boolean isConcrete() { 059 return !(isInterface() || isAbstract()); 060 } 061 062 /** 063 * Return whether the underlying class is marked as 'final'. 064 */ 065 boolean isFinal(); 066 067 /** 068 * Determine whether the underlying class is independent, i.e. whether 069 * it is a top-level class or a nested class (static inner class) that 070 * can be constructed independently from an enclosing class. 071 */ 072 boolean isIndependent(); 073 074 /** 075 * Return whether the underlying class is declared within an enclosing 076 * class (i.e. the underlying class is an inner/nested class or a 077 * local class within a method). 078 * <p>If this method returns {@code false}, then the underlying 079 * class is a top-level class. 080 */ 081 default boolean hasEnclosingClass() { 082 return (getEnclosingClassName() != null); 083 } 084 085 /** 086 * Return the name of the enclosing class of the underlying class, 087 * or {@code null} if the underlying class is a top-level class. 088 */ 089 @Nullable 090 String getEnclosingClassName(); 091 092 /** 093 * Return whether the underlying class has a super class. 094 */ 095 default boolean hasSuperClass() { 096 return (getSuperClassName() != null); 097 } 098 099 /** 100 * Return the name of the super class of the underlying class, 101 * or {@code null} if there is no super class defined. 102 */ 103 @Nullable 104 String getSuperClassName(); 105 106 /** 107 * Return the names of all interfaces that the underlying class 108 * implements, or an empty array if there are none. 109 */ 110 String[] getInterfaceNames(); 111 112 /** 113 * Return the names of all classes declared as members of the class represented by 114 * this ClassMetadata object. This includes public, protected, default (package) 115 * access, and private classes and interfaces declared by the class, but excludes 116 * inherited classes and interfaces. An empty array is returned if no member classes 117 * or interfaces exist. 118 * @since 3.1 119 */ 120 String[] getMemberClassNames(); 121 122}