java - Purpose of having custom annotations -


some projects using of custom annotations below. example below. please explain me

  1. when should take decision have custom annotations.
  2. role of @target & @retention annotation attributes
  3. is better use import java.lang.annotation.target , import java.lang.annotation.retention or hibernate specific annotations below

    @entity @table(name = "creditcard")

    @creditcardentity

    public class creditcard implements java.io.serializable {}  import java.lang.annotation.elementtype; import java.lang.annotation.retention; import java.lang.annotation.retentionpolicy; import java.lang.annotation.target; import org.hibernate.validator.validatorclass;  @target( { elementtype.type }) @retention(retentionpolicy.runtime) public @interface creditcardentity {}   } 

if plan use same annotations on more 1 place in code, it's idea use custom annotations. example, in case, if use @entity @table(name = "creditcard") in place, it's idea unite them under 1 annotation creditcardentity annotation, but if that's place use 2 annotations (which more in case), it's unnecessary make custom annotation it.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -