Java Metadata Summary: Use and definition of Java annotations

Source: Internet
Author: User
Tags comments deprecated

The metadata is translated from the word metadata, which means "data on data". More and more open source frameworks provide "meta data" support, in fact, annotation support. Today the system learns Java annotations (Java metadata). The contents of this article are not limited to the comments of Javadoc.

1. What is Java metadata and what is the role?

metadata, which is "data about data." There are a lot of features too. You may have used the annotations of Javadoc to automatically generate documents. This is one of the meta data features. In general, metadata can be used to create documents, track code dependencies, perform compile-time format checks, and replace existing configuration files (such as hibernate also provides annotation configurations)

Note has 3 basic types

A. Tag annotations--No variables, only name identification. For example @annotation

B. Single value annotations-provides a piece of data based on a markup annotation. such as @annotation ("data")

C. Full comments-You can include multiple data members, each of which consists of a name and a value.

@annotation (val1= "data1", val2= "Data2")

2.Java "Notes"

3 built-in annotation types available in Java

A. Override, only for methods (not for classes, package declarations, or other constructs)

Function: can guarantee the correctness of the declaration of override function at compile time

Usage: @Override

public void Fun () {.}

B.deprecated also can only function and method

Function: Annotate a method that should not be reused

Usage: @Deprecated public void fun{///They say this annotation is on the same line as the function

C.supresswarnings can annotate a piece of code

Role: Turn off specific warning messages, such as when you are using generics without specifying a type

Usage: @SupressWarnings (value={"Unchecked"})

.. Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.