@Data notes the role of JavaBean

Today, when looking at the code, see this comment, I have not seen before, so we checked, the discovery was a good comment, you can make the code more concise.

This annotation from lombok, lombok possible to reduce the amount of template code, @Data reduced when using annotations, you need to import lombok.Data, annotations listed below under lombok provided:

val: val same name and the scala, the type can be determined at run time;

@NonNull: Notes on the parameters, if the class parameter is null, it will report the anomaly, throw new NullPointException (parameter name)

@Cleanup: Note Before reference variables, automatic resource recovery default call close () method

@ Getter / @ Setter: annotation on the class, the class to provide a read-write property

@Getter(lazy=true) :

@ToString: annotation on the class, the class provides toString () method

@EqualsAndHashCode: annotation on the class, the class provides equals () and hashCode () method

@NoArgsConstructor, @RequiredArgsConstructor, @AllArgsConstructor: annotation on the class, the class provides no arguments, parameters have to be specified, all reference constructor

@Data: annotation on the class to provide read-write property class, in addition to providing a equals (), hashCode (), toString () method

@Value :

@Builder: Notes on the class, a class inside the Builder

@SneakThrows :

@Synchronized: Notes on the method, a method of providing synchronization lock

@Log :

@ Log4j: annotation on the class, the class provides a property called the log4j log log objects

@ Slf4j: annotation on the class, the class provides a property called the log4j log log objects



@Cleanup("dispose") org.eclipse.swt.widgets.CoolBar bar = new CoolBar(parent, 0);
@Cleanup InputStream in = new FileInputStream(args[0]);
@Cleanup OutputStream out = new FileOutputStream(args[1]);

Some notes are included above relationship, what ways of looking at what is required by the increased annotation, @ Log4j and annotation @ Slf4j effect is not small, the layers can be used to facilitate the fight log.

You can also view the official website [  official website  ] 

Guess you like

Origin www.cnblogs.com/deityjian/p/11080149.html