Class Metamodel


  • public class Metamodel
    extends Object
    Represents the Spoon metamodel (incl. at runtime)
    • Field Detail

      • MODEL_IFACE_PACKAGES

        public static final Set<String> MODEL_IFACE_PACKAGES
        qualified names of packages which contain interfaces of spoon model
      • MODEL_CLASS_PACKAGES

        public static final Set<String> MODEL_CLASS_PACKAGES
        qualified names of packages which contain classes (implementations) of spoon model
    • Constructor Detail

      • Metamodel

        public Metamodel​(File spoonJavaSourcesDirectory)
        Not in the public API. Parses spoon sources and creates factory with spoon model.
        Parameters:
        spoonJavaSourcesDirectory - the root directory of java sources of spoon model. The directory must contain "spoon" directory.
      • Metamodel

        protected Metamodel​(Factory factory)
        Parameters:
        factory - already loaded factory with all Spoon model types
    • Method Detail

      • getAllMetamodelInterfaces

        public static Set<CtType<?>> getAllMetamodelInterfaces()
        Returns all interfaces of the Spoon metamodel. This method is stateless for sake of maintenance. If you need to call it several times, you should store the result.
      • getInstance

        public static Metamodel getInstance()
        Returns:
        Spoon Metamodel, which is built once and then returns cached version
      • getAllInstantiableMetamodelInterfaces

        public List<CtType<? extends CtElement>> getAllInstantiableMetamodelInterfaces()
        Returns:
        List of Spoon model interfaces, which represents instantiable leafs of Spoon metamodel
      • getConceptName

        public static String getConceptName​(CtType<?> type)
        Parameters:
        type - a spoon model class or interface, whose concept name has to be returned
        Returns:
        name of MetamodelConcept, which represents Spoon model CtType
      • getImplementationOfInterface

        public static CtClass<?> getImplementationOfInterface​(CtInterface<?> iface)
        Parameters:
        iface - the interface of spoon model element
        Returns:
        CtClass of Spoon model which implements the spoon model interface. null if there is no implementation.
      • getInterfaceOfImplementation

        public static CtInterface<?> getInterfaceOfImplementation​(CtClass<?> impl)
        Parameters:
        impl - the implementation class of a Spoon element
        Returns:
        CtInterface of Spoon model which represents API of the spoon model class. null if there is no implementation.
      • getRoleOfMethod

        public static CtRole getRoleOfMethod​(CtMethod<?> method)
        Parameters:
        method - to be checked method
        Returns:
        CtRole of spoon model method. Looking into all super class/interface implementations of this method