[JAVA-15438] Added example to showcase @Generated on constructors (#12946)

Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com>
This commit is contained in:
panos-kakos 2022-10-29 16:48:12 +01:00 committed by GitHub
parent fad70d5b4e
commit c97bebc822
2 changed files with 7 additions and 1 deletions

View File

@ -4,12 +4,13 @@ import java.lang.annotation.Documented;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME; import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Documented @Documented
@Retention(RUNTIME) @Retention(RUNTIME)
@Target({TYPE, METHOD}) @Target({TYPE, METHOD, CONSTRUCTOR})
public @interface Generated { public @interface Generated {
} }

View File

@ -4,6 +4,11 @@ import com.baeldung.jacocoexclusions.generated.Generated;
public class CustomerService { public class CustomerService {
@Generated
public CustomerService(){
//constructor excluded form coverage report
}
//this method will be excluded from coverage due to @Generated. //this method will be excluded from coverage due to @Generated.
@Generated @Generated
public String getProductId() { public String getProductId() {