Contractor
Annotate your MVP Contract interface to automatically generate your component classes
Premise
This library aims to minimise the MVP setup boilerplate code to the minimum. Decorate your Contract interfaces, build, and extend the generated abstract classes. Your contract functions will be there, as well as all needed references. The MODEL and the VIEW will contain references to the PRESENTER, and the PRESENTER to both the MODEL and the VIEW. Enhance further by setting Base classes which will be extended by the generated abstract classes.
Install
implementation 'com.izikode.izilib:contractor:0.1'
annotationProcessor 'com.izikode.izilib:contractor:0.1'
- or with kotlin
implementation 'com.izikode.izilib:contractor:0.1'
kapt 'com.izikode.izilib:contractor:0.1'
Sample usage
a. Create and decorate yout contract
@Contract
interface MainContract {}
b. Create and decorate your component interfaces
@Contract
interface MainContract {
@Contract.Model
interface Model {}
@Contract.View
interface View {}
@Contract.Presenter
interface Presenter {}
}
c. Write your functions and BUILD
d. Extend the generated classes for your final implementation
class MainPresenter : AbstractMainPresenter() {}
- Naming convention
interface MainContract PLUS interface Model GENERATES AbstractMainModel
e. Initialize the Objects and References
val model = MainModel()
val view = MainView()
val presenter = MainPresenter()
presenter.setup(model).setup(view)
- Access the references simply through
model()
view()
presenter()
f. Optionally, set a target build package
@Contract(target = "com.somepackage")
g. Optionally, have your components extend BASE classes
@Contract.Model(base = BaseModel::class)
interface Model
TODO
- Use javapoet for code generation
- Finilize logic and implementation for the Contractor class (possibly creating objects and setup automatically)
Licence
Copyright 2018 Fanie Veizis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.