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 predefined defaults.static voidregisterDefaultParametersFor(java.lang.Class<?> component, java.lang.Class<?>... defaultParameters)Registers the types (i.e.
-
-
-
Method Detail
-
getInstance
public static <T> T getInstance(java.lang.Class<T> component, java.lang.Object... params) throws it.unive.lisa.AnalysisSetupExceptionCreates an instance of the givencomponent. Ifparamsare provided, a suitable (and not ambiguous) constructor must exist incomponent's class. If noparamshave been provided but default parameters have been registered throughregisterDefaultParametersFor(Class, Class...),getInstance(Class, Object...)will be used to create such parameters and those will be used. 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:
it.unive.lisa.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 predefined defaults. 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
-
registerDefaultParametersFor
public static void registerDefaultParametersFor(java.lang.Class<?> component, java.lang.Class<?>... defaultParameters)Registers the types (i.e. implementations) of the parameters to use for the creation of the given component. These will be used whenevergetInstance(Class, Object...)orgetDefaultFor(Class, Object...)are invoked without specifying parameters but a default exist. Any previous default forcomponentintroduced by calling this method is removed.- Parameters:
component- the component whose default parameters are to be registereddefaultParameters- the new parameters for the creation ofcomponent
-
getDefaultFor
public static <T> T getDefaultFor(java.lang.Class<T> component, java.lang.Object... params) throws it.unive.lisa.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 is looked up in the predefined defaults. Ifcomponentdoes not have a predefined default, then anAnalysisSetupExceptionis thrown. Then,getInstance(Class, Object...)is invoked on the retrieved instance, using the givenparams. If noparamshave been provided but default parameters have been registered throughregisterDefaultParametersFor(Class, Class...),getInstance(Class, Object...)will be used to create such parameters and those will be used. 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:
it.unive.lisa.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
-
-