podam icon indicating copy to clipboard operation
podam copied to clipboard

Complete PodamAnnotation Target value to allow lombok full usage

Open liam-kincaid opened this issue 2 years ago • 6 comments

May you change the PodamAnnotation from: ` package uk.co.jemos.podam.common;

    import java.lang.annotation.Documented;
    import java.lang.annotation.ElementType;
    import java.lang.annotation.Retention;
    import java.lang.annotation.RetentionPolicy;
    import java.lang.annotation.Target;

    /**
     * Annotation to mark PODAM annotations.
     * 
     * 
     * @author maxdidato
     * 
     */
    @Documented
    @Target({ElementType.ANNOTATION_TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    public @interface PodamAnnotation {
    }

`

to: ` package uk.co.jemos.podam.common;

    import java.lang.annotation.Documented;
    import java.lang.annotation.ElementType;
    import java.lang.annotation.Retention;
    import java.lang.annotation.RetentionPolicy;
    import java.lang.annotation.Target;

    /**
     * Annotation to mark PODAM annotations.
     * 
     * 
     * @author maxdidato
     * 
     */
    @Documented
    @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD})
    @Retention(RetentionPolicy.RUNTIME)
    public @interface PodamAnnotation {
    }

` to be use with "lombok". The addition of ElementType.METHOD allow the use on parameter "onMethod_" in lombok initialisation.

liam-kincaid avatar Dec 31 '23 11:12 liam-kincaid

Hi,

PodamAnnotation is an annotation to annotate other annotations. It is not supposed to be applied to the methods. So @Target is correct.

Thanks, Daniil

daivanov avatar Dec 31 '23 12:12 daivanov

In this case, you could change all over annotation, like PodamIntValue, etc Is-it possible ?

liam-kincaid avatar Dec 31 '23 12:12 liam-kincaid

In my understanding you should be doing something like this with lombok

import lombok.Getter;
import lombok.Setter;
import uk.co.jemos.podam.common.PodamIntValue;

public class Example {

  @Getter @Setter @PodamIntValue(minValue = 0, maxValue = 10) private int value;
  
}

I'm not sure why there is a need for on onMethod_ parameter.

Thanks, Daniil

daivanov avatar Dec 31 '23 13:12 daivanov

Ok, I explain. I use a custom build method in a builder with hibernate validation. As you guest, I use @With. Read a sample User.tar.gz

This illustrate my purpose

liam-kincaid avatar Dec 31 '23 15:12 liam-kincaid

You have class User with a constructor

User(final UserBuilder builder)

And class UserBuilder with a constructor public UserBuilder(@NotNull final User user)

This cannot work. But again I don't see a reason why you try to add podam annotations to a method.

Thanks, Daniil

daivanov avatar Dec 31 '23 16:12 daivanov

I use delombok and I saw my bad. I want to have this: @With(onParam_={ @PodamIntValue(minValue = 1) }) to generate this: public UserBuilder withId(@PodamIntValue(minValue = 1) Long _id) { You could close this Issue. Sorry and thanks you again

liam-kincaid avatar Jan 01 '24 12:01 liam-kincaid