public final class ModelHelper
extends java.lang.Object
Models.| Modifier and Type | Class and Description |
|---|---|
static class |
ModelHelper.MethodExecutionContext
A helper class grouping
MethodExecutionInfo and ValueCalculator as the
execution context of a method. |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
allParticular(java.util.List<Value> values)
Simple helper method to check if all values in the given list are particular.
|
static boolean |
areInstanceAndParametersParticular(MethodExecutionInfo executionInfo)
Check whether both the instance (for instance methods) and all parameters of a method call are
particular.
|
static MethodResult |
createDefaultBuilderResult(ModelHelper.MethodExecutionContext context,
java.lang.Object newInstance)
Helper to create a method result containing "this", the instance a method has been called on.
|
static MethodResult |
createDefaultConstructorResult(ModelHelper.MethodExecutionContext context,
Model concreteValue)
Helper to create a value from a standard modeled constructor call.
|
static MethodResult |
createDefaultReturnResult(ModelHelper.MethodExecutionContext context,
@Nullable java.lang.Object concreteValue)
Helper to create a value from a standard modeled method call.
|
static MethodResult |
createUnknownBuilderResult(ModelHelper.MethodExecutionContext context)
Helper to create a method result containing "this" with unknown value.
|
static MethodResult |
executeViaHandler(ModelHelper.MethodExecutionContext context,
java.util.Map<BasicMethodInfo,java.lang.reflect.Method> handlers,
Model instance)
Utility method to execute a modeled method on a model using the provided Map of supported
handlers.
|
static <T extends ReflectiveModel<T>> |
getConstructorHandlers(java.lang.Class<T> modelClass)
Given a model class, use reflection to build a mapping from
BasicMethodInfos used by
the analysis to identify a constructor to the Method handler to the method modeling it,
in order to be able to invoke it. |
static <T extends ReflectiveModel<T>> |
getDummyObject(java.lang.Class<T> modelClass) |
static <T extends ReflectiveModel<T>> |
getInstanceMethodHandlers(java.lang.Class<T> modelClass)
Given a model class, use reflection to build a mapping from
BasicMethodInfos used by
the analysis to identify an instance method to the Method handler to the method
modeling it, in order to be able to invoke it. |
static <T extends ReflectiveModel<T>> |
getStaticMethodHandlers(java.lang.Class<T> modelClass)
Given a model class, use reflection to build a mapping from
BasicMethodInfos used by
the analysis to identify an instance method to the Method handler to the method
modeling it, in order to be able to invoke it. |
static <T extends ReflectiveModel<T>> |
getSupportedMethods(java.lang.Class<T> modelClass) |
public static <T extends ReflectiveModel<T>> java.util.Map<BasicMethodInfo,java.lang.reflect.Method> getConstructorHandlers(java.lang.Class<T> modelClass)
BasicMethodInfos used by
the analysis to identify a constructor to the Method handler to the method modeling it,
in order to be able to invoke it.
The model needs to annotate the methods modeling constructors with ModeledConstructor.
modelClass - the Model's classpublic static <T extends ReflectiveModel<T>> java.util.Map<BasicMethodInfo,java.lang.reflect.Method> getInstanceMethodHandlers(java.lang.Class<T> modelClass)
BasicMethodInfos used by
the analysis to identify an instance method to the Method handler to the method
modeling it, in order to be able to invoke it.
The model needs to annotate the methods modeling instance methods with ModeledInstanceMethod.
modelClass - the Model's classpublic static <T extends ReflectiveModel<T>> java.util.Map<BasicMethodInfo,java.lang.reflect.Method> getStaticMethodHandlers(java.lang.Class<T> modelClass)
BasicMethodInfos used by
the analysis to identify an instance method to the Method handler to the method
modeling it, in order to be able to invoke it.
The model needs to annotate the methods modeling instance methods with ModeledInstanceMethod.
modelClass - the Model's classpublic static <T extends ReflectiveModel<T>> T getDummyObject(java.lang.Class<T> modelClass)
public static <T extends ReflectiveModel<T>> java.util.Collection<BasicMethodInfo> getSupportedMethods(java.lang.Class<T> modelClass)
public static boolean allParticular(java.util.List<Value> values)
values - Values to check.public static boolean areInstanceAndParametersParticular(MethodExecutionInfo executionInfo)
executionInfo - information on a method execution.public static MethodResult executeViaHandler(ModelHelper.MethodExecutionContext context, java.util.Map<BasicMethodInfo,java.lang.reflect.Method> handlers, Model instance)
context - The method execution context.handlers - Map of BasicMethodInfo to Methods which are supported.instance - Instance to execute the method on.java.lang.UnsupportedOperationException - If a method without handler is requested.java.lang.RuntimeException - For any exception during reflective execution of the method.public static MethodResult createDefaultConstructorResult(ModelHelper.MethodExecutionContext context, Model concreteValue)
context - The method execution context.concreteValue - The value of the constructed object.public static MethodResult createDefaultReturnResult(ModelHelper.MethodExecutionContext context, @Nullable @Nullable java.lang.Object concreteValue)
context - The method execution context.concreteValue - The value of the returned object, can be precise or a Model.public static MethodResult createDefaultBuilderResult(ModelHelper.MethodExecutionContext context, java.lang.Object newInstance)
Usually, this would be used on classes with a fluent interface, e.g. setters when using the Builder design pattern:
Builder setValue(value) {
this.value = value; // modify instance
return this;
}context - The method execution context.newInstance - The new instance, can be precise or a Model.public static MethodResult createUnknownBuilderResult(ModelHelper.MethodExecutionContext context)
Usually, this would be used on classes with a fluent interface, e.g. setters when using the Builder design pattern:
Builder setValue(value) {
this.value = value; // modify instance
return this;
}context - The method execution context.