Transform

Renaming Repository methods.

Sometimes it happens that a method name gets way too long and the code, which uses the method, looks very.. interesting.. (spaghetti-code)

To reduce the length of names and make en2do more customizable, I created the @Transform annotation.

Now you can rename any method to what it really does and just annotate it with

  • @Transform("{realMethodNameDeclaration}")

and just write the method declaration into the annotation itself.

ATTENTION: No worries, en2do still validates all parts of the method name and treats it like a normal declared method.

Example of transforming method names:

@Collection("customer_repository")
public interface CustomerRepository extends Repository<Customer, UUID> {

    // Other methods go here...

    @Transform("existsByStreet")
    boolean myTransformedMethod(String street);

    @Transform("findManyByStreet")
    List<Customer> myTransformedMethod2(String street);
}

Last updated