Skip to content

Package: Main

Main

nameinstructionbranchcomplexitylinemethod
Main()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
main(String[])
M: 0 C: 78
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 20
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * TheseFoolishThings: Miscellaneous utilities
5: * http://tidalwave.it/projects/thesefoolishthings
6: *
7: * Copyright (C) 2009 - 2024 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/thesefoolishthings-src
22: * git clone https://github.com/tidalwave-it/thesefoolishthings-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.thesefoolishthings.examples.jpafinderexample;
27:
28: import javax.annotation.Nonnull;
29: import it.tidalwave.util.As;
30: import it.tidalwave.util.AsExtensions;
31: import it.tidalwave.thesefoolishthings.examples.jpafinderexample.impl.JpaPersonRegistry;
32: import it.tidalwave.thesefoolishthings.examples.jpafinderexample.role.Findable;
33: import it.tidalwave.thesefoolishthings.examples.person.Person;
34: import it.tidalwave.thesefoolishthings.examples.person.PersonRegistryHelper;
35: import lombok.experimental.ExtensionMethod;
36: import lombok.extern.slf4j.Slf4j;
37: import static it.tidalwave.thesefoolishthings.examples.jpafinderexample.PersonRegistry3.*;
38: import static it.tidalwave.thesefoolishthings.examples.jpafinderexample.role.Findable._Findable_;
39: import static it.tidalwave.util.Finder.SortDirection.DESCENDING;
40:
41: /***************************************************************************************************************************************************************
42: *
43: * @author Fabrizio Giudici
44: *
45: **************************************************************************************************************************************************************/
46: @ExtensionMethod(AsExtensions.class)
47: @Slf4j
48: public class Main
49: {
50: private static final As.Type<Findable<Person>> _Findable_of_Person_ = As.type(_Findable_);
51:
52: public static void main (@Nonnull final String... args)
53: {
54: try (final var txManager = TxManager.getInstance())
55: {
56: final PersonRegistry3 registry = new JpaPersonRegistry(txManager);
57: PersonRegistryHelper.populate(registry);
58:
59: final var p1 = registry.findPerson().results();
60: log.info("******** All: {}", p1);
61:
62: final var n1 = registry.findPerson().count();
63: log.info("******** Count: {}", n1);
64:
65: final var p2 = registry.findPerson().from(3).max(2).results();
66: log.info("******** Two persons from the 3rd position: {}", p2);
67:
68: final var p3 = registry.findPerson().sort(BY_FIRST_NAME).results();
69: log.info("******** All, sorted by first name: {}", p3);
70:
71: final var p4 = registry.findPerson().sort(BY_LAST_NAME, DESCENDING).results();
72: log.info("******** All, sorted by last name, descending: {}", p4);
73:
74: final var p5 = Person.prototype().as(_Findable_of_Person_).find()
75: .sort(BY_LAST_NAME, DESCENDING)
76: .from(2)
77: .max(3)
78: .results();
79: log.info("******** Three persons from the 2nd position, with Person.as(): {}", p5);
80: }
81: }
82: }