Questions tagged [java-annotations]

211 questions
0
votes
0 answers

Inheritance in annotations

I'm trying to make a method that returns fields that are annotated with a specific annotation. I have one annotation (TestAnn) that I want to be a superclass for the other two (AutoSave and AutoLoad). TestAnn: public @interface TestAnn { …
Rubix327
  • 45
  • 5
0
votes
1 answer

Why is Spring's @Component Annotation RUNTIME?

I am wondering, why Spring's implementation of the @Component Annotation has RetentionPolicy.RUNTIME. Here's the official implementation from github @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Indexed public @interface…
wanshurst
  • 13
  • 1
0
votes
1 answer

why annotating with @Configuration and @EnableWebSecurity at the same time

I'm reading Spring in Action 5th Edition. in part 4 (securing spring), he wanted to overide the security autoconfigured by spring boot... so he created a config class called it SecurityConfig as follow: @Configuration @EnableWebSecurity public class…
mouad36
  • 306
  • 2
  • 10
0
votes
1 answer

Getting Spring Boot to load annotated resources defined inside runtime dependencies

I am developing a bunch of Java/Sprint Boot webservices that will all have several identical (ideally, reusable) Spring-based resources: many annotation-based Spring Security configurations several @Services and @Components many annotation-based…
hotmeatballsoup
  • 385
  • 6
  • 58
  • 136
0
votes
1 answer

How to scale a PDAnnotation?

I have a pdf that has been passed to me with a signature (annotation) and I have to scale the pdf, but when I scale the pdf the annotation does not scale, and it comes out out out of shape. Any suggestions? I'll show you the code of the method and…
PereZix
  • 41
  • 4
0
votes
2 answers

Bean-Validate minimum and maximum value for LocalDate

I would like to provide bean-validation for variable which is of the LocalDate type. The minimum acceptable value should be LocalDate.of(2020,1,1). The maximum acceptable value should be LocalDate.of(5874897,1,1).
0
votes
0 answers

How to make custom annotation throw an error instead of default message

I am working on an api that allows the user to fetch data by id, where the id's data type is a UUID. I would like to use an annotation in the controller method to check whether the user passed a valid UUID, but @Valid doesn't work on UUID's, so I…
Riggster
  • 107
  • 3
  • 15
0
votes
2 answers

Making a method level annotation that tells the method to save all logs to database

My problem is that a lot of methods in my project now require to have their logs stored, AOP isn't very viable since there isn't an appropriate point to cut, so I'm thinking about making a custom annotation and putting it wherever it's…
Teddy Tsai
  • 414
  • 1
  • 13
0
votes
0 answers

Java custom annotation to make target class extend another class

In a spring boot project I'm working on, we have a lot of classes that extend Consumer, Processor, or Producer custom abstract classes. All these concrete extension classes are also annotated with @Component, @ConditionalOnProperty and usually…
gz90
  • 41
  • 7
0
votes
1 answer

Check if Annotation is inherited

I have an annotation and three classes like this: @Inherited @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface MyAnnotation {} @MyAnnotation public class MySuperClass {} public class MySubClassA extends MySuperClass…
maddingl
  • 197
  • 4
  • 20
0
votes
0 answers

How to Create annotations which can declare variable using class name from its usage

following public class Testclass { private static final LogExtension log = new LogExtension(Testclass.class); } should work with just: @LogExtension public class Testclass{} similar to @Slf4j with its annotation it creates an object like in…
Optimus Prime
  • 69
  • 2
  • 13
0
votes
0 answers

Inherit property from parent class and add attribute to the inherited annotation

I have a derived class MyBusinessBody which extends a parent class BusinessBody. One field in BusinessBody looks like: public class BusinessBody{ @OneToOne(fetch = FetchType.LAZY) private Trade trade; //setter and getter ... } Now, I want…
J.E.Y
  • 1,173
  • 2
  • 15
  • 37
0
votes
1 answer

How to get annotations of JUnit test suite class?

I have such an example of test suite class to run many test classes at once in JUnit 4.13. @RunWith(Suite.class) @SuiteClasses({ FirstTest.class, SecondTest.class }) @TestSuiteAnnotation public class TestSuite { } These are my test…
kosteklvp
  • 147
  • 2
  • 16
0
votes
2 answers

if functional interface came in java version 8 then how @FunctionalInterface annotation working in java version 7 or less

@FunctionalInterface interface inter1 { public void show(); } this program compiles and runs fine when I used 1.6 version to compile
0
votes
0 answers

How can we consolidate the working of a java class into a custom annotation?

I am very new to Java and to annotations. So far, I have been using a .jar file to be imported for my java classes to work. For example, there is a source code for "Controller". I make java objects that inherits the source class Controller and its…