Package it.unive.lisa
Class LiSAFactory
- java.lang.Object
-
- it.unive.lisa.LiSAFactory
-
public final class LiSAFactory extends java.lang.Object
An 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 class
LiSAFactory.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.ConfigurableComponent
s that can be used to customize the analysis.static <T> T
getDefaultFor(java.lang.Class<T> component, java.lang.Object... params)
Builds the default instance of the specified analysis component.static <T> T
getInstance(java.lang.Class<T> component, java.lang.Object... params)
Creates an instance of the givencomponent
.static void
registerDefaultFor(java.lang.Class<?> component, java.lang.Class<?> defaultImplementation)
Registers a default implementation forcomponent
, taking precedence over the predefined defaults.static void
registerDefaultParametersFor(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.AnalysisSetupException
Creates an instance of the givencomponent
. Ifparams
are provided, a suitable (and not ambiguous) constructor must exist incomponent
's class. If noparams
have 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 ofcomponent
is 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 forcomponent
introduced 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 forcomponent
introduced 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.AnalysisSetupException
Builds 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 forcomponent
has been provided, then the instance is looked up in the predefined defaults. Ifcomponent
does not have a predefined default, then anAnalysisSetupException
is thrown. Then,getInstance(Class, Object...)
is invoked on the retrieved instance, using the givenparams
. If noparams
have 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 aNonRelationalDomain
and the component is aHeapDomain
orValueDomain
, then the instance is wrapped into the appropriate environment (eitherHeapEnvironment
orValueEnvironment
) 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.ConfigurableComponent
s that can be used to customize the analysis.- Returns:
- the components that can be configured
-
-