Questions tagged [java-annotations]
211 questions
1
vote
1 answer
Retrieve value of annotation for an enum
I have these annotations:
@interface NotNull {
boolean value() default false;
}
@interface Type {
Class> value();
}
and then I use them with an enum:
public enum KeyMap implements IMapEnum {
@Type(Integer.class)
@NotNull
…
user1604294
1
vote
0 answers
Is it possible to conditionally apply annotation in an annotation?
I'm trying to do something like the following:
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface AnnotationOne {
boolean annotationTwoToggler() default false
{
if (annotationTwoToggler) {
//…

AAM111
- 1,178
- 3
- 19
- 39
1
vote
1 answer
No Qualifying Bean When Bean is Defined
I have been trying to get a setup where I create the PostDatedAchInReader which implements JdbcCursorItemReader and then injected that into the PostDatedAchInAggregatingJdbcItemReader which collects read objects based on a specific criteria and…

Patrick Aquilone
- 584
- 2
- 11
- 28
1
vote
0 answers
JAVA Custom Annotation: Restricting annotation parameters on certain condition
I'm starting to learn java annotation and I want to use this as some sort of Generator label. I want to generate random texts only, numbers only or text and numbers.
Here is my custom annotation:
public @interface RandomGenerator {
public int…

TraxX
- 382
- 2
- 13
1
vote
1 answer
Is there any annotation equivalent for Guice's bindEagerSingleton()?
I did something like this
bindEagerSingleton(MyClass.class);
Can I do something like this
@SomeAnnotation
public class MyClass {}
Thank you!

ddreian
- 1,766
- 5
- 21
- 29
1
vote
1 answer
Lombok + javac: cannot find symbol
I'm trying to get started with Lombok. As the official demo and the documentation state one should be able to compile a class with lombok annotation with following simple steps:
Create a class and include @Data annotation in the code. Should be…

Pavel Smirnov
- 21
- 5
1
vote
1 answer
Is there a list of java annotations?
I have been a C++ and Javascript programmer. Now I am working in Java, Java Spring, and Java Springboot.
Whenever I read Java code in a book or an article, I get thrown by an annotation. There seem to be hundreds of them! I have found…

user2171796
- 397
- 2
- 16
1
vote
3 answers
Adding validation in RequestMapping annotation
I am using spring boot and I want to add API versioning support for some of the RequestMapping (url path should start with /v[1-9]+/).
I am thinking of creating an annotation: MyRequestMapping that additionally supports the api versioning path. This…

Kumar Gaurav
- 729
- 3
- 9
- 21
1
vote
1 answer
Java Annotation or Code Generation
Give a nested class definition
class A {
B b;
public B getB() {
return b;
}
}
class B {
ArrayList list;
public getListC() {
return list;
}
}
class C {
D d;
public D getD() {
return d;
}
}
class D {
E…

Big O
- 417
- 1
- 5
- 14
1
vote
1 answer
Reading cucumber Jvm tag programmatically
I am trying to reuse my existing integration test cucumber Gherkin scenarios for performance test using Gatling. Integration tests are written in restassured.io and cucumber JVM. What I am trying to do is adding a new tag to existing integration…

Deepu Nair
- 165
- 5
- 15
1
vote
3 answers
Is there any way to include the name of the interface when implementing the method
Is there any way to include the name of the interface when implementing the method? If I have to implement 3 interfaces, then it would be hard to remind me where the implemented method comes from.
If I have 2 interface required to implement the same…

Ming Leung
- 385
- 2
- 13
1
vote
0 answers
Java Annotation - Accessing annotation on private field using Bean introspector (not using Field object)
Before marking it duplicate, please note that this is very specific question with specific scenario and I have already search extensively the forum to get any clue towards answer. Please make sure that the query in this post is addressed completely…

Gyanendra Dwivedi
- 5,511
- 2
- 27
- 53
1
vote
2 answers
How to Infer Information in Custom Annotation with Java
I created a custom annotation called CrudSearchable and have defined some attributes there. However, the attributes I am assigning are already visible from the bean. Is there a way I can grab these values without having to redefine them manually?…

wheeleruniverse
- 1,511
- 2
- 20
- 37
1
vote
2 answers
Using more than one @XStreamAlias annotation for same element
How to use more than one @XStreamAlias annotation on same element. When I do like this:
@XStreamAlias("alias1")
@XStreamAlias("alias2")
class ABC{
//
}
I get compilation error. Is there any way to achieve this?

Vivek Mangal
- 532
- 1
- 8
- 24
1
vote
2 answers
Custom Java annotation to skip the method execution
I want to create a custom annotation to skip method execution
This is my annotation code, with the validator class
@Target({ METHOD , FIELD , PARAMETER } )
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy={MyValidator .class})
public…

Ashish Shetkar
- 1,414
- 2
- 18
- 35