Interface ParameterizedToolingModelBuilder<T>
-
- Type Parameters:
T
- The type of parameter used by this model builder.
- All Superinterfaces:
ToolingModelBuilder
public interface ParameterizedToolingModelBuilder<T> extends ToolingModelBuilder
AToolingModelBuilder
which can be parameterized by the client.The parameter type
T
must be an interface and must follow a contract described ingetParameterType()
.The parameter type
T
does not need to implement the interface defined in the client side, but it does need to have the same structure. The Tooling API will create a view from the client side parameter type to the one defined in this model builder, and deal automatically with missing methods in order to allow evolution of the models.All classes implementing this interface should also implement methods from
ToolingModelBuilder
, which will be used to determine if a model can be built by the current builder and to generate the model in case no parameter is passed from the client. The parameter type should be bound to the model type.- Since:
- 4.4
- See Also:
ToolingModelBuilder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Object
buildAll(java.lang.String modelName, T parameter, Project project)
Creates the model of the given type for the given project using the given parameter.java.lang.Class<T>
getParameterType()
Returns the expected type of the parameter.-
Methods inherited from interface org.gradle.tooling.provider.model.ToolingModelBuilder
buildAll, canBuild
-
-
-
-
Method Detail
-
getParameterType
java.lang.Class<T> getParameterType()
Returns the expected type of the parameter.Contract
The parameter type must conform to the following rules:
- It must be an interface.
- It must contain only getter-like and setter-like methods.
- There must be one getter corresponding to exactly one setter, with matching value types.
For each getter-like method:
- The name must start with
"get"
or"is"
, followed by an uppercase letter. - It must have no parameters.
- The return type must not be
void
.
For each setter-like method:
- The name must start with
"set"
, followed by an uppercase letter. - It must have exactly one parameter.
- The return type must be
void
.
Example
Here is an example of a valid parameter type declaration:
public interface MyParameter { String getValue(); void setValue(String value); boolean isFlag(); void setFlag(boolean value); }
- Returns:
- The type of the parameter.
-
buildAll
java.lang.Object buildAll(java.lang.String modelName, T parameter, Project project)
Creates the model of the given type for the given project using the given parameter.- Parameters:
modelName
- The model name, usually the same as the name of the Java interface used by the client.parameter
- The parameter received from the client.project
- The project to create the model for.- Returns:
- The model.
-
-