Package it.unive.lisa
Class LiSAFactory
- java.lang.Object
-
- it.unive.lisa.LiSAFactory
-
public final class LiSAFactory extends java.lang.ObjectAn utility class for instantiating analysis components, that is, modular pieces of the analysis that have several implementations. The default instance for a component can be retrieved throughgetDefaultFor(Class, Object...), while a specific instance can be retrieved throughgetInstance(Class, Object...). Note that custom defaults for each component can be defined throughregisterDefaultFor(Class, Class).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLiSAFactory.ConfigurableComponent<T>An analysis component that can be configured, that is, it has more than one implementation that can be modularly integrated into the analysis.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Collection<LiSAFactory.ConfigurableComponent<?>>configurableComponents()Yields the collection ofLiSAFactory.ConfigurableComponents that can be used to customize the analysis.static <T> TgetDefaultFor(java.lang.Class<T> component, java.lang.Object... params)Builds the default instance of the specified analysis component.static <T> TgetInstance(java.lang.Class<T> component, java.lang.Object... params)Creates an instance of the givencomponent.static voidregisterDefaultFor(java.lang.Class<?> component, java.lang.Class<?> defaultImplementation)Registers a default implementation forcomponent, taking precedence over the defaults defined throughDefaultImplementation.
-
-
-
Method Detail
-
getInstance
public static <T> T getInstance(java.lang.Class<T> component, java.lang.Object... params) throws AnalysisSetupExceptionCreates an instance of the givencomponent. Ifparamsare provided, a suitable constructor (and not ambiguous) must exist incomponent's class. Otherwise,component's class in inspected for the presence of aDefaultParametersannotations. If found, the instance will be created by passing to the constructor instances of those parameters obtained throughgetInstance(Class, Object...)without passing anyparams. Otherwise, the nullary constructor ofcomponentis invoked.- Type Parameters:
T- the type of the component- Parameters:
component- the component to instantiateparams- the parameters for the creation- Returns:
- an instance of the given component
- Throws:
AnalysisSetupException- if the component cannot be created
-
registerDefaultFor
public static void registerDefaultFor(java.lang.Class<?> component, java.lang.Class<?> defaultImplementation)Registers a default implementation forcomponent, taking precedence over the defaults defined throughDefaultImplementation. Any previous default forcomponentintroduced by calling this method is removed.- Parameters:
component- the component whose default implementation is to be registereddefaultImplementation- the new default implementation forcomponent
-
getDefaultFor
public static <T> T getDefaultFor(java.lang.Class<T> component, java.lang.Object... params) throws AnalysisSetupExceptionBuilds the default instance of the specified analysis component. The instance to create is retrieved by first looking into the custom defaults provided throughregisterDefaultFor(Class, Class)If no entry forcomponenthas been provided, then the instance from thecomponent'sDefaultImplementationannotation. Ifcomponentis not annotated with such an annotation, then anAnalysisSetupExceptionis thrown. Then,getInstance(Class, Object...)is invoked on the retrieved instance, using the givenparams. If the default instance is aNonRelationalDomainand the component is aHeapDomainorValueDomain, then the instance is wrapped into the appropriate environment (eitherHeapEnvironmentorValueEnvironment) before being returned.- Type Parameters:
T- the type of the component- Parameters:
component- the component to instantiateparams- the parameters for the creation of the default instance- Returns:
- an instance of the default implementation of the given component
- Throws:
AnalysisSetupException- if the default implementation cannot be created
-
configurableComponents
public static java.util.Collection<LiSAFactory.ConfigurableComponent<?>> configurableComponents()
Yields the collection ofLiSAFactory.ConfigurableComponents that can be used to customize the analysis.- Returns:
- the components that can be configured
-
-