V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
andreby
V2EX  ›  Java

各位开发中常用哪些注解?

  •  
  •   andreby · 2016-10-11 10:09:15 +08:00 · 4430 次点击
    这是一个创建于 2726 天前的主题,其中的信息可能已经有所发展或是发生改变。
    第 1 条附言  ·  2016-10-21 11:17:11 +08:00
    蛤 O(∩_∩)O 哈!
    29 条回复    2016-10-20 15:19:02 +08:00
    CFO
        1
    CFO  
       2016-10-11 10:44:31 +08:00 via Android
    我来给你召唤个人 @override
    caomaocao
        2
    caomaocao  
       2016-10-11 10:46:23 +08:00
    liuxey
        3
    liuxey  
       2016-10-11 10:59:37 +08:00
    misaka19000
        4
    misaka19000  
       2016-10-11 11:34:31 +08:00 via Android
    acoder2013
        5
    acoder2013  
       2016-10-11 11:43:26 +08:00
    Lucups
        6
    Lucups  
       2016-10-11 11:46:22 +08:00
    sudoz
        7
    sudoz  
       2016-10-11 11:48:09 +08:00
    leopku
        8
    leopku  
       2016-10-11 13:45:27 +08:00
    awolfly9
        9
    awolfly9  
       2016-10-11 13:50:12 +08:00
    @TODO... @Debug...
    liuhao2050qq
        10
    liuhao2050qq  
       2016-10-11 13:52:58 +08:00
    @login_required 逃。。
    macfee
        11
    macfee  
       2016-10-11 15:10:52 +08:00
    bwangel
        12
    bwangel  
       2016-10-11 15:14:18 +08:00
    Pythoner 路过,偷偷召唤一下 @property
    yidinghe
        13
    yidinghe  
       2016-10-11 15:16:58 +08:00 via Android
    sherlocktheplant
        14
    sherlocktheplant  
       2016-10-11 15:59:34 +08:00
    居然没有 @Inject @Autowired
    lzhd24
        15
    lzhd24  
       2016-10-11 16:01:16 +08:00 via Android
    acros
        16
    acros  
       2016-10-11 16:09:30 +08:00   ❤️ 1
    //Hack
    //Warning
    //TODO
    //Temporary Code
    //Only For Debug
    //WTF?
    //Need polish
    //Need refactor

    // Date - 20xx-xx-xx
    BOOM
        17
    BOOM  
       2016-10-11 16:15:20 +08:00 via Android
    @macfee note7 是不是爱死我了
    sutra
        18
    sutra  
       2016-10-11 16:51:30 +08:00   ❤️ 3
    $ find . -iname '*.java' | xargs sed -n 's/.*\(@[a-zA-Z0-9]\{1,\}\).*/\1/p' | sort | uniq -c | sort -nr | pbcopy

    173 @Override
    143 @inheritDoc
    127 @Column
    63 @Autowired
    43 @RequestMapping
    41 @param
    36 @Generated
    35 @RolesAllowed
    27 @PathVariable
    26 @Service
    24 @Nullable
    24 @Nonnull
    23 @Path
    23 @Bean
    21 @link
    20 @return
    18 @StaticMetamodel
    18 @Access
    16 @Transient
    16 @Transactional
    16 @ForeignKey
    16 @Controller
    15 @GET
    14 @Entity
    13 @Table
    12 @XmlTransient
    12 @RequestParam
    12 @BeanParam
    10 @XmlRootElement
    9 @ManyToOne
    9 @JoinColumn
    8 @Version
    7 @UniqueConstraint
    7 @SuppressWarnings
    7 @Produces
    7 @PathParam
    6 @OneToOne
    5 @Test
    5 @SortableField
    5 @POST
    5 @ModelAttribute
    5 @Field
    5 @ConfigurationProperties
    4 @throws
    4 @see
    4 @MappedSuperclass
    4 @JsonIgnoreProperties
    4 @Consumes
    4 @Configuration
    4 @ComponentScan
    3 @Scheduled
    3 @QueryParam
    3 @Query
    3 @EnableJpaAuditing
    3 @EnableAspectJAutoProxy
    3 @Context
    3 @Component
    2 @Type
    2 @Singleton
    2 @Provider
    2 @Profile
    2 @PreAuthorize
    2 @PersistenceContext
    2 @Parameter
    2 @PUT
    2 @Id
    2 @GenericGenerator
    2 @GeneratedValue
    2 @EntityScan
    2 @EnableScheduling
    2 @EnableJpaRepositories
    2 @EnableAutoConfiguration
    2 @DefaultValue
    2 @DateBridge
    2 @CacheResult
    1 @literal
    1 @io
    1 @author
    1 @SpringBootApplication
    1 @Resource
    1 @Qualifier
    1 @OrderBy
    1 @Order
    1 @OneToMany
    1 @ManyToMany
    1 @LastModifiedDate
    1 @LastModifiedBy
    1 @JoinTable
    1 @Indexed
    1 @ImportResource
    1 @EntityListeners
    1 @EnableWebSecurity
    1 @EnableJms
    1 @EnableGlobalMethodSecurity
    1 @EnableCaching
    1 @DELETE
    1 @CreatedDate
    1 @CreatedBy
    1 @Analyzer
    sutra
        19
    sutra  
       2016-10-11 17:29:26 +08:00
    修正一下:利用大写开头排除掉注释里的 @param @return 等,支持下划线

    $ find . -iname '*.java' | xargs sed -n 's/.*\(@[A-Z][a-zA-Z0-9_]\{0,\}\).*/\1/p' | sort | uniq -c | sort -nr | pbcopy

    173 @Override
    127 @Column
    63 @Autowired
    43 @RequestMapping
    36 @Generated
    35 @RolesAllowed
    27 @PathVariable
    26 @Service
    24 @Nullable
    24 @Nonnull
    23 @Path
    23 @Bean
    18 @StaticMetamodel
    18 @Access
    16 @Transient
    16 @Transactional
    16 @ForeignKey
    16 @Controller
    15 @GET
    14 @Entity
    13 @Table
    12 @XmlTransient
    12 @RequestParam
    12 @BeanParam
    10 @XmlRootElement
    9 @ManyToOne
    9 @JoinColumn
    8 @Version
    7 @UniqueConstraint
    7 @SuppressWarnings
    7 @Produces
    7 @PathParam
    6 @OneToOne
    5 @Test
    5 @SortableField
    5 @POST
    5 @ModelAttribute
    5 @Field
    5 @ConfigurationProperties
    4 @MappedSuperclass
    4 @JsonIgnoreProperties
    4 @Consumes
    4 @Configuration
    4 @ComponentScan
    3 @Scheduled
    3 @QueryParam
    3 @Query
    3 @EnableJpaAuditing
    3 @EnableAspectJAutoProxy
    3 @Context
    3 @Component
    2 @Type
    2 @Singleton
    2 @Provider
    2 @Profile
    2 @PreAuthorize
    2 @PersistenceContext
    2 @Parameter
    2 @PUT
    2 @Id
    2 @GenericGenerator
    2 @GeneratedValue
    2 @EntityScan
    2 @EnableScheduling
    2 @EnableJpaRepositories
    2 @EnableAutoConfiguration
    2 @DefaultValue
    2 @DateBridge
    2 @CacheResult
    1 @SpringBootApplication
    1 @Resource
    1 @Qualifier
    1 @OrderBy
    1 @Order
    1 @OneToMany
    1 @ManyToMany
    1 @LastModifiedDate
    1 @LastModifiedBy
    1 @JoinTable
    1 @Indexed
    1 @ImportResource
    1 @EntityListeners
    1 @EnableWebSecurity
    1 @EnableJms
    1 @EnableGlobalMethodSecurity
    1 @EnableCaching
    1 @DELETE
    1 @CreatedDate
    1 @CreatedBy
    1 @Analyzer
    zhenizhui
        20
    zhenizhui  
       2016-10-11 18:18:16 +08:00
    这得 at 多少人出来。。。
    iMono
        21
    iMono  
       2016-10-11 18:39:16 +08:00
    zhangchioulin
        22
    zhangchioulin  
       2016-10-12 09:54:10 +08:00 via Android
    @brief
    @discussion
    @param
    #warning
    #pragma mark -
    param
        23
    param  
       2016-10-12 09:56:52 +08:00
    @param 是我的
    @Override 也是我的
    Override
        24
    Override  
       2016-10-12 09:57:42 +08:00
    我仿佛又听到有人在背后偷偷 @我
    Override
        25
    Override  
       2016-10-12 09:58:31 +08:00
    @sutra 我也干过这种事,于是我注册了 Override 和 param
    Override
        26
    Override  
       2016-10-12 10:02:23 +08:00
    我用

    grep -RPoh --exclude-dir='.git' --exclude-dir='node_modules' '@\w+' 2> /dev/null | sort | uniq -c | sort -n

    找到

    503 @transition
    507 @alert
    513 @test
    517 @store
    534 @MIT
    558 @OpenSSL
    569 @RM
    574 @class
    576 @y
    583 @xml
    587 @V
    589 @columns
    589 @private
    592 @s
    594 @top_level
    607 @index
    609 @latin
    628 @t
    645 @S
    670 @behdad
    672 @android
    683 @classmethod
    692 @string
    741 @parser
    776 @x
    781 @popover
    793 @app
    806 @keithp
    843 @dummy
    854 @openssl
    858 @tooltip
    882 @attr
    912 @ngdoc
    912 @type
    945 @_
    975 @btn
    975 @import
    981 @state
    985 @description
    1013 @am__nodep
    1024 @padding
    1030 @am__include
    1065 @border
    1103 @echo
    1115 @to
    1118 @returns
    1119 @input
    1128 @grid
    1129 @T
    1144 @start
    1156 @insns
    1193 @list
    1225 @panel
    1251 @static
    1279 @end
    1329 @font
    1366 @drawable
    1383 @fa
    1432 @section
    1435 @screen
    1439 @author
    1447 @dimen
    1511 @line
    1513 @Override
    1538 @name
    1598 @options
    1645 @example
    1661 @method
    1708 @see
    1729 @file
    1740 @XMM
    1860 @style
    1969 @am__quote
    2140 @property
    2188 @navbar
    2202 @AMDEPBACKSLASH
    2226 @am__fastdepCC_TRUE
    2488 @X
    3071 @color
    3141 @AMDEP_TRUE
    3141 @gmail
    3258 @am__fastdepCC_FALSE
    4885 @return
    5020 @media
    5510 @link
    6484 @cryptsoft
    17094 @param
    param
        27
    param  
       2016-10-12 10:32:25 +08:00
    @CFO
    sutra
        28
    sutra  
       2016-10-12 10:33:52 +08:00
    @Override 你这个是 GNU Grep (也就是常用在 Linux 上) 吧? BSD Grep (也就是常用在 Mac 上的)没有 -P 。
    sunwei0325
        29
    sunwei0325  
       2016-10-20 15:19:02 +08:00
    最多的就是 @Test
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5895 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 02:13 · PVG 10:13 · LAX 19:13 · JFK 22:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.