Chain call
# Chain advantages
- Clean code, high readability, easy to maintain.
- Significantly reduce the amount of code, "code high", the old man next door in the annual debriefing proudly said: that year I put my hands in my pockets, a little out, a line of code to fix all!
- Coding cool, for developers, the chain has a very obvious advantage is to write code is very cool, with the editor friendly tips can quickly through the drop-down + enter to complete the code, this feeling is like leaders like to do multiple-choice questions rather than fill in the blanks!
- ...
# Chain Constructors
The conditional constructors and the methods in them originally support Lambda+chaining, but in order to further improve the chaining, the old man next door can realize the need to pretend to be 13 at the annual meeting, We provide a chaining method for each conditional constructor.
// Index Chain Constructor
LambdaEsIndexChainWrapper<T> lambdaChainIndex(BaseEsMapper<T> baseEsMapper);
// Query chain constructor
LambdaEsQueryChainWrapper<T> lambdaChainQuery(BaseEsMapper<T> baseEsMapper);
// Update (including delete) chain constructor
LambdaEsUpdateChainWrapper<T> lambdaChainUpdate(BaseEsMapper<T> baseEsMapper);
1
2
3
4
5
6
2
3
4
5
6
The above constructors are dependent on the EsWrappers (Wrappers in MP) tool class
# Use cases
@Test
public void testOne() {
// chain call written by the old man next door
Document document = EsWrappers.lambdaChainQuery(documentMapper).eq(Document::getTitle, "Old Man Next Door").one();
}
@Test
public void testSelectOne() {
// Half-assed chain call written by the old man next door
LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
wrapper.eq(Document::getTitle, "The Old King Next Door")
.limit(1);
Document document = documentMapper.selectOne(wrapper);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
提示
If the leader does not know much about technology, this 13 will be installed by the old man, the old man's chain call in all aspects seem to have more advantages! So the old man next door smoothly promoted, the year-end prize is higher, marry the rich white beauty, the old king next door fainted in the toilet...
Help us improve this document (opens new window)
Last update: 2024/03/29