Spring helpers
is additional library for Spring framework
which provides additional annotations for generation common spring structures (such as repositories, controllers, etc).
This project contains three modules:
- annotations-lib - contains only annotations which will be used in processors
- processors-lib - contains processors which creates codes according to your annotation usage
- experiment - temporary module, which will be used for testing during developing
By the help of @JpaRepositoty
will be created same named structure for your entities, which you will easily inject in your spring project.
Moreover, you will be able to specify custom methods by additional annotation @Method
@Entity
@JpaRepository({
@Method(name = "findAllByName", returnType = List.class, args = {String.class}),
@Method(name = "findAllByNameAndId", returnType = List.class, args = {String.class, Long.class}),
@Method(name = "getNameById", returnType = String.class, args = {Long.class}, query = "Select u.name from ExampleEntity u where u.id = ?1")
})
public class ExampleEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
//geters & setters
}
public interface ExampleEntityRepository extends JpaRepository<ExampleEntity, Long> {
List<ExampleEntity> findAllByName(String arg0);
List<ExampleEntity> findAllByNameAndId(String arg0, Long arg1);
@Query("Select u.name from ExampleEntity u where u.id = ?1")
String getNameById(Long arg0);
}
- doesn't exist direct access to annotated class, therefore there is no simple way to get class properties .
- doesn't exist easy way to update annotated class, in this way should be used
AST
(Abstract syntax tree). - creating some classes could be too complicated to code (for instance, generic classes full of methods which directs to parameter or annotated class), as a possible solution will be added additional module with custom templating engine, which perform transformations from prepared code-templates to java classes.
@JpaRepository
- creates interface of JpaRepository<Entity,Id>@RestCrudController
- creates spring RestController with CRUD methods (validation will be provided)@CrudController
- creates spring Controller with CRUD methods (validation will be provided)@CrudOperations
- inserts to existing (Rest)Controller CRUD methods (validation will be provided)- TODO: think about other structures
Javapoet
- library for easier way to write java classes in time of processingSpring framework
- source of data structures which will be generated by processing