当前位置:网站首页>Basic knowledge in the project
Basic knowledge in the project
2022-07-25 21:45:00 【I can't get up in the morning!】
List of articles
Boolean.TRUE and true Performance comparison
- A,D > B,C
// 7.844
Boolean A(){
return Boolean.TRUE;
}
// 10.109
boolean B(){
return Boolean.TRUE
}
// 7.906
Boolean C(){
return true;
}
// 7.828
boolean D(){
return true;
}
The string is empty isEmpty and isBlank The difference between
- isEmpty Just judge the null and length as 0 character string
- isBlank The judgment is empty , The length is 0, Blank character ( Including Spaces , tabs \t, A newline \n, Page identifier \f, enter \r) Composed string
StringUtils.isEmpty(null) = true
StringUtils.isEmpty("") = true
StringUtils.isEmpty(" ") = false
StringUtils.isEmpty("aaa") = false
StringUtils.isEmpty("\t \n \r \f") = false
StringUtils.isBlank(null) = true
StringUtils.isBlank("") = true
StringUitls.isBlank(" ") = true
StringUtils.isEmpty("aaa") = false
StringUtils.isEmpty("\t \n \r \f") = true
- hutool Tools :StrUtil
System.out.println(StrUtil.isEmpty(null)); // true
System.out.println(StrUtil.isEmpty("")); // true
System.out.println(StrUtil.isEmpty(" ")); // false
System.out.println(StrUtil.isEmpty("aaa")); // false
System.out.println(StrUtil.isEmpty("\r \t \n \f")); // false
System.out.println(StrUtil.isBlank(null)); // true
System.out.println(StrUtil.isBlank("")); // true
System.out.println(StrUtil.isBlank(" ")); // true
System.out.println(StrUtil.isBlank("aaa")); // false
System.out.println(StrUtil.isBlank("\r \n \t \f")); // true
Swagger-ApiModel and ApiModelProperty
- ApiModel annotation : This attribute is to describe the interface related entity classes that need special description
| The attribute name | Attribute types | The default value is | effect |
|---|---|---|---|
| value() | String | empty | Name of custom class |
| description() | String | empty | Add long text description information to the class |
- ApiModelProperty annotation : This attribute is a description of the parameters in the entity class
| The attribute name | Attribute types | The default value is | effect |
|---|---|---|---|
| value() | String | empty | Define parameter description information |
| name() | String | empty | Define the parameter name |
| required() | boolean | false | Define whether parameters must be passed |
| hidden() | boolean | false | Define whether the parameter is hidden |
| allowEmptyValue() | boolean | false | Define whether the parameter can be null |
@ApiModel(value = " User entity , Store user related fields ", description = " The user entity contains all business fields related to the user , If necessary, please add another ")
public class User{
// do something...
}
@ApiModelProperty(value = " user Id")
private Integer id;
Swagger-ApiOperation and ApiParam
- @ApiOperation Annotations are not Spring Self contained , It is swagger Inside com.wordnik.swagger.annotations.ApiOperation;
- annotation @ApiOperation and @ApiParam It's used to build Api Document
- @ApiOperation(value=“ Interface specification ”,httpMethod=“ Interface request mode ”,response=“ Interface return parameter type ”,notes=“ Interface release notes ”), Used in the method of request , Explain the purpose of the method 、 effect
- @ApiParam(required =“ Whether the parameter ”,name=“ Parameter name ”,value=“ Parameter description ”)
Other notes :
- @ApiImplicitParams: Used in the method of request , Represents a set of parameter descriptions
- @Api: For the requested class , Represents a description of a class
- @ApiImplicitParams: Used in the method of request , Represents a set of parameter descriptions
- @ApiResponses: Used in the method of request , Represents a set of responses
- Reference link
BeanUtils.copyProperties
Shallow copy , If they are all single attributes , So it's not about deep copy , Suitable for use BeanUtils
BeanUtils.copyProperties(a, b);
- b Properties that exist in ,a There must be , however a There can be extra attributes in the ;
- a China and b The same attributes in the are replaced , Whether it's worth it or not ;
- a、 b The attributes in the should have the same name , Can be assigned , Otherwise, manual assignment is required ;
- Spring Of BeanUtils Of CopyProperties The corresponding properties required by the method are getter and setter Method ;
- If there is an inner class with exactly the same properties , But not the same inner class , That is, they belong to their own internal classes , be spring Will think that the properties are different , Can't copy;
- spring and apache Of copy The position of the method source and destination parameters of the property is exactly the opposite , Therefore, we should pay attention to both guiding package and calling
边栏推荐
- 【测开方法论】测开平台pk心得-抉择
- 如何用 Redis 实现分布式锁的?
- Vivo official website app full model UI adaptation scheme
- Six principles of C program design
- C#Socket
- Simple use of protobuf
- 【饭谈】软件测试薪资层次和分段(修仙)
- Handwriting distributed configuration center (1)
- 全志芯片bsp命名规则
- [interview: concurrent Part 24: multithreading: comprehensive exercise] sequence control
猜你喜欢

Detailed explanation of Ag search tool parameters

函数栈帧的创建和销毁

如何用 Redis 实现分布式锁的?

Per capita Swiss number series, Swiss number 4 generation JS reverse analysis

【Redis底层解析】字符串类型

少儿编程 电子学会图形化编程等级考试Scratch一级真题解析(判断题)2022年6月

The adequacy of source evaluation forum · observation model test

Redis 使用详解
![[Flink] flick rocksdbliststate reports an error you cannot add null to a liststate](/img/c0/1923e17f166ab4bc7d20f48398f366.jpg)
[Flink] flick rocksdbliststate reports an error you cannot add null to a liststate

How to choose sentinel vs. hystrix current limiting?
随机推荐
Isn't it too much to play Gobang in idea?
[introduction to C language] zzulioj 1016-1020
SSH private key realizes login to remote target server
C#常见的集合
人脸与关键点检测:YOLO5Face实战
Sentinel vs Hystrix 限流对比,到底怎么选?
Idea resolves the prompt of profile properties disappear
分享|智慧消防应急管理平台解决方案(附PDF)
若依如何解决导出使用下载插件出现异常?
新版Maixhub部署(V831与K210)
Naming rules for BSP of Quanzhi chip
Research on the scheme of MySQL advanced (VIII) sorting problem
C#程序设计的6大原则
[Flink] flick rocksdbliststate reports an error you cannot add null to a liststate
Trusted and controllable way of Tencent cloud database
Bitcoin.com:usdd represents a truly decentralized stable currency
Job interviews are always a second kill? After reading the seckill system notes secretly stored by JD T8, I have given my knees
【饭谈】测试平台为什么有组件化?模块化?很多看不到的地方设计的很好是种浪费么?
Create EDA - why should I learn EDA
[interview: concurrent Article 23: multithreading: Join] re understanding of join