Questions tagged [java-annotations]
211 questions
0
votes
1 answer
Allow custom annotation only one one method per class
I have a annotation @ToolExecution. At the moment I use annotation processing and throwing Error to ensure that only one method is annotated with this annotation.
Is there an native way to create a constraint and allow my custom annotation to be…

xetra11
- 7,671
- 14
- 84
- 159
0
votes
1 answer
Spring AOP: Advice on annotation used over another advice
I have created my custom annotation:
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Condition {
String value();
}
I want to use this annotation to determine whether or…

qwerty1423
- 295
- 5
- 17
0
votes
1 answer
Using @Contract with Android Studio
I'm trying to use the @Contract annotation of IntelliJ but in Android Studio. I can't import it, it's not there. On the website explaining it, it's said to add /lib/annotations.jar to the project's classpath using the Project…

Nicolas
- 6,611
- 3
- 29
- 73
0
votes
1 answer
Why won't the preview server in Eclipse respect my @WebServlet annotation?
I am using the @WebServlet annotation in my app, like so:
@WebServlet("/tokenize")
public class TokenizerServlet extends HttpServlet {
...
}
This does not work in the "J2EE Preview at localhost" within Eclipse. Any request to…

Deane
- 8,269
- 12
- 58
- 108
0
votes
0 answers
@WebFilter annotation with web module 3 - confused about multiple url patterns
I'm really confused about the WebFilter annotation with Dynamic Web Modules >= 3.0. I read this article ( https://www.concretepage.com/java-ee/jsp-servlet/how-to-use-filter-in-servlet-3-with-webfilter-annotation ) telling that @WebFilter cannot be…

nagylzs
- 3,954
- 6
- 39
- 70
0
votes
1 answer
java annotation can not receive param as const array
first I use annotation to receive some params, String and String[], e.g.
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface RedisCacheAble {
String value() default "";
String[] names()…

vvsueprman
- 143
- 1
- 2
- 10
0
votes
2 answers
Updating field attributes by annotation
I'm reviewing how reflection works or possible work. I have this SomeClassBuilder wherein it has an attribute target : Target with declared annotation TargetAnnotation.
Thing is, is it possible to override/update the values/properties of Target…

David B
- 3,269
- 12
- 48
- 80
0
votes
1 answer
Java Annotation encoding with Thymeleaf
I've got a nasty problem with my Java Annotation:
@Pattern(regexp = "(...)", message = "(...) Tekst in Polish (...)")
private String ip;
This is linked to my view using BindingResult and Thymeleaf:

gczarnocki
- 173
- 1
- 16
0
votes
1 answer
Servlet works on Eclipse but not on Tomcat server "The requested resource is not available."
I created a servlet that worked on Eclipse but gives me
"The requested resource is not available."
When accessed on my tomcat server at http://cs3.calstatela.edu:8080/cs3220stu48/Labs/RequestSummary
yet works when on…

STRAN
- 73
- 1
- 8
0
votes
1 answer
How add the @CompileStatic annotation to package scope in groovy
I would like to enforce static linking for a whole package in groovy. Static linking requires use of CompileStatic. I would like to avoid restating this on every class. How can I apply this as a package-level annotation. I have found no reference to…

Jörn Guy Süß
- 1,408
- 11
- 18
0
votes
2 answers
Getting "Invlalid minute value = ?" from java @Schedule annotation
Got an issue today when trying to use a Java @Schedule annotation on one of my methods. Error is as follows:
Severe: Exception while deploying the app [MyApp-ear] : Error processing EjbDescriptor
java.lang.RuntimeException: ScheduleManager:…

Daefect91
- 128
- 8
0
votes
0 answers
Can Java Annotation get value from a Method and then return another value for that method
public class Investor {
final String name;
int id ;
public Investor(String name, int id) {
super();
this.name = name;
this.id = id;
}
@MaskName
public String getName() {
return name;
}
public int getId() {
return…

Shivam Kashyap
- 77
- 1
- 7
0
votes
0 answers
apache spark: what is the best way to run initialization script upon instantiating a new executor
I am using a custom dropwizard metrics source and reporter. Everything works great when I invoke metrics directly but not through metrics-annotations.
In the code below calls to testTimer works without requiring to register the source with Spark…

sgireddy
- 155
- 10
0
votes
1 answer
Get property value of annotation (used on a class, not method)
Scenario is something like below...
@Component
@Migration(description="Test Description", serial="")
public class TestUpdate1 {
}
I need to get the value of description
i.e. "Test Description"
How can I do that

neelrotno
- 159
- 2
- 8
0
votes
1 answer
Can you generate code the overrides a method using Java annotations?
Is it possible to write a Java annotation for a class that generates a method that overrides the class's parent method?
In my case I want to do it in android:
@OverrideOnTouch
class Foo extends Activity {
And it will generate an onTouch override…

LBoy
- 71
- 1
- 8