Questions tagged [java-annotations]

184 questions
88
votes
3 answers

what is the use of annotations @Id and @GeneratedValue(strategy = GenerationType.IDENTITY)? Why the generationtype is identity?

@Id @GeneratedValue(strategy = GenerationType.IDENTITY) Why we are using this annotations? i need to know if this autoincrement my table id values. (GenerationType.IDENTITY) is there any other types whats actually happening when we use this…
Lijo
  • 4,738
  • 1
  • 41
  • 55
52
votes
4 answers

Is a Python Decorator the same as Java annotation, or Java with Aspects?

Are Python Decorators the same or similar, or fundamentally different to Java annotations or something like Spring AOP, or Aspect J?
bn.
  • 7,031
  • 7
  • 37
  • 53
49
votes
2 answers

Difference between @EntityScan and @ComponentScan

I am trying to understand the difference here. I see that a class has been annotated with both of them with same package example : @Configuration @EntityScan("some.known.persistence") @ComponentScan({ "some.known.persistence"}) public class…
Raghuveer
  • 2,248
  • 3
  • 29
  • 55
43
votes
1 answer

Using Room's @ForeignKey as @Entity parameter in Kotlin

I came across a Room tutorial that makes use of the @PrimaryKey annotation on the class definition: @Entity(foreignKeys = @ForeignKey(entity = User.class, parentColumns = "id", childColumns…
Chisko
  • 2,935
  • 6
  • 24
  • 41
27
votes
2 answers

Android studio warning - InnerClass annotations are missing corresponding EnclosingMember annotations

I recently upgraded to Android Studio 3.1 and upon building my Kotlin with Java project I got the following warning. InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored. Message…
j2emanue
  • 51,417
  • 46
  • 239
  • 380
20
votes
1 answer

How to suppress lombok warnings

I have an Entity @Builder class MyEntity { private Set children = new HashSet<>() } And i get a lombok warning. warning: @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve…
Bukharov Sergey
  • 7,996
  • 3
  • 31
  • 48
14
votes
2 answers

Visual Studio Code - Java - Lombok - The method is undefined for the type

I downloaded the following project and imported it into Visual Studio Code: https://github.com/oktadeveloper/okta-spring-boot-2-angular-5-example I have a problem on the following class, when invoking:…
davidesp
  • 2,546
  • 6
  • 25
  • 59
12
votes
1 answer

Annotation processing, RoundEnvironment.processingOver()

While reading the code of a custom annotation processor in Java, I noticed this piece of code in the processor's process method: @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { if…
Mohammed Aouf Zouag
  • 16,366
  • 3
  • 36
  • 64
11
votes
2 answers

How to create a customisation annotation for splitting request param and collect return result?

I have a method params is a list which is lager than 50000 items; Limited to the business logic, the list must less than 30000, so that I have a method to split this array to 2d array before the logic public static final Collection>…
Ben Luk
  • 645
  • 1
  • 8
  • 15
9
votes
1 answer

About the parameter defined in process(...) method of Processor interface

In javax.annotation.processing package there is a interface Processor in which there is a function: /** * Processes a set of annotation types on type elements * originating from the prior round and returns whether or not * these…
Leem.fin
  • 35,699
  • 70
  • 166
  • 297
9
votes
1 answer

Writing custom lint warning to check for custom annotation

I have written the following annotation: import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import…
Moses
  • 1,787
  • 2
  • 18
  • 27
7
votes
2 answers

Why does JPMS allow annotation types as services

In introducing JPMS services, section 7.7.4 of the Java Language Specification notes that "The service type must be a class type, an interface type, or an annotation type." I'm struggling to see the point of permitting an annotation. My…
Toby Eggitt
  • 1,686
  • 15
  • 20
7
votes
4 answers

Mocking the Qualified beans using mockito for a spring-boot application

consider my scenario public class SomeClass { @Autowired @Qualifier("converter1") private IConverter converter1; @Autowired @Qualifier("converter2") private IConverter converter2; public void doSomeAction(String mimeType) { …
amith
  • 319
  • 2
  • 9
7
votes
2 answers

POJOs generated by jsonschema2pojo have annotation which Android Studio doesn't understand

When I generate POJOs via http://www.jsonschema2pojo.org/ I get something like this: import javax.annotation.Generated; import com.google.gson.annotations.Expose; import…
6
votes
2 answers

What's is the difference between a static and non-static annotation?

Java's inner classes can be static or non-static. Non-static inner classes are tied to an instance of the enclosing class. Annotations are a type of Java interface, and like any other class, they can be defined inside a class. Similarly, they can be…
Brandon Yarbrough
  • 33,119
  • 22
  • 98
  • 134
1
2 3
12 13