Package ai.libs.jaicore.components.model
Class ComponentInstanceUtil
- java.lang.Object
-
- ai.libs.jaicore.components.model.ComponentInstanceUtil
-
public class ComponentInstanceUtil extends java.lang.ObjectThe 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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckComponentInstantiation(ComponentInstance ci)Checks whether a component instance adheres to the defined inter-parameter dependencies defined in the component.static java.lang.StringgetComponentInstanceAsComponentNames(IComponentInstance instance)static java.lang.StringgetComponentInstanceString(IComponentInstance ci)static java.util.Collection<IComponent>getContainedComponents(IComponentInstance ci)static IComponentInstancegetDefaultParametrization(IComponentInstance ci)static booleanisDefaultConfiguration(IComponentInstance instance)static booleanisSubInstance(IComponentInstance sub, IComponentInstance sup)static booleanisValidComponentInstantiation(ComponentInstance ci)Checks whether a component instance adheres to the defined inter-parameter dependencies defined in the component.static booleanmatchesPathRestriction(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.static booleanmatchesPathRestrictions(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.static ComponentInstancesampleDefaultComponentInstance(java.lang.String requiredInterface, java.util.Collection<? extends IComponent> components, java.util.Random rand)Samples a random component instance with default parameters.static ComponentInstancesampleRandomComponentInstance(java.lang.String requiredInterface, java.util.Collection<IComponent> components, java.util.Random rand)Samples a random component instance with random parameters.static java.lang.StringtoComponentNameString(IComponentInstance ci)static java.lang.StringtoRecursiveConstructorString(IComponentInstance ci)
-
-
-
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
-
getDefaultParametrization
public static IComponentInstance getDefaultParametrization(IComponentInstance ci)
-
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)
-
isSubInstance
public static boolean isSubInstance(IComponentInstance sub, IComponentInstance sup)
-
toRecursiveConstructorString
public static java.lang.String toRecursiveConstructorString(IComponentInstance ci)
-
-