Class ComponentInstanceUtil


  • public class ComponentInstanceUtil
    extends java.lang.Object
    The ComponentInstanceUtil provides some utilities to deal with component instances. For instance, it may be used to check whether a ComponentInstance conforms the dependencies defined in the respective Component.
    • Method Detail

      • isValidComponentInstantiation

        public static boolean isValidComponentInstantiation​(ComponentInstance ci)
        Checks whether a component instance adheres to the defined inter-parameter dependencies defined in the component.
        Parameters:
        ci - The component instance to be verified.
        Returns:
        Returns true iff all dependency conditions hold.
      • checkComponentInstantiation

        public static void checkComponentInstantiation​(ComponentInstance ci)
        Checks whether a component instance adheres to the defined inter-parameter dependencies defined in the component.
        Parameters:
        ci - The component instance to be verified.
        Throws:
        java.lang.Exception - with explanation if it is not valid
      • isDefaultConfiguration

        public static boolean isDefaultConfiguration​(IComponentInstance instance)
      • sampleRandomComponentInstance

        public static ComponentInstance sampleRandomComponentInstance​(java.lang.String requiredInterface,
                                                                      java.util.Collection<IComponent> components,
                                                                      java.util.Random rand)
        Samples a random component instance with random parameters.
        Parameters:
        requiredInterface - The required interface the sampled component instance must conform.
        components - The components that can be chosen.
        rand - Random number generator for pseudo randomization.
        Returns:
        A randomly sampled component instance with random parameters.
      • sampleDefaultComponentInstance

        public static ComponentInstance sampleDefaultComponentInstance​(java.lang.String requiredInterface,
                                                                       java.util.Collection<? extends IComponent> components,
                                                                       java.util.Random rand)
        Samples a random component instance with default parameters.
        Parameters:
        requiredInterface - The required interface the sampled component instance must conform.
        components - The components that can be chosen.
        rand - Random number generator for pseudo randomization.
        Returns:
        A randomly sampled component instance with default parameters.
      • matchesPathRestrictions

        public static boolean matchesPathRestrictions​(ComponentInstance ci,
                                                      java.util.Collection<java.util.List<ai.libs.jaicore.basic.sets.Pair<java.lang.String,​java.lang.String>>> paths)
        This method checks, whether a given list of paths of refinements conforms the constraints for parameter refinements.
        Parameters:
        paths - A list of paths of refinements to be checked.
        Returns:
        Returns true if everything is alright and false if there is an issue with the given paths.
      • matchesPathRestriction

        public static boolean matchesPathRestriction​(ComponentInstance ci,
                                                     java.util.List<ai.libs.jaicore.basic.sets.Pair<java.lang.String,​java.lang.String>> path)
        This method checks, whether a path of refinements conforms the constraints for parameter refinements.
        Parameters:
        path - A path of refinements to be checked.
        Returns:
        Returns true if everything is alright and false if there is an issue with the given path.
      • getContainedComponents

        public static java.util.Collection<IComponent> getContainedComponents​(IComponentInstance ci)
        Returns:
        A collection of all components contained (recursively) in this ComponentInstance.
      • toComponentNameString

        public static java.lang.String toComponentNameString​(IComponentInstance ci)
      • getComponentInstanceAsComponentNames

        public static java.lang.String getComponentInstanceAsComponentNames​(IComponentInstance instance)
      • getComponentInstanceString

        public static java.lang.String getComponentInstanceString​(IComponentInstance ci)
      • toRecursiveConstructorString

        public static java.lang.String toRecursiveConstructorString​(IComponentInstance ci)