Skip to content

Package: DisplayableExample

DisplayableExample

nameinstructionbranchcomplexitylinemethod
DisplayableExample()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
run()
M: 0 C: 59
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
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.dci.displayable;
27:
28: import it.tidalwave.util.AsExtensions;
29: import it.tidalwave.util.Id;
30: import it.tidalwave.thesefoolishthings.examples.person.Person;
31: import lombok.experimental.ExtensionMethod;
32: import lombok.extern.slf4j.Slf4j;
33: import static it.tidalwave.thesefoolishthings.examples.dci.displayable.role.Renderable._Renderable_;
34: import static it.tidalwave.role.ui.Displayable._Displayable_;
35:
36: /***************************************************************************************************************************************************************
37: *
38: * @author Fabrizio Giudici
39: *
40: **************************************************************************************************************************************************************/
41: // START-SNIPPET: extensionmethod
42: @ExtensionMethod(AsExtensions.class) @Slf4j
43: public class DisplayableExample
44: {
45: public void run()
46: {
47: final var joe = new Person(new Id("1"), "Joe", "Smith");
48: final var luke = new Person(new Id("2"), "Luke", "Skywalker");
49: // approach with classic getter
50: log.info("******** (joe as Displayable).displayName: {}", joe.as(_Displayable_).getDisplayName());
51: log.info("******** (luke as Displayable).displayName: {}", luke.as(_Displayable_).getDisplayName());
52: // approach oriented to Tell Don't Ask
53: joe.as(_Renderable_).renderTo("******** (joe as Renderable): %1$s %2$s ", log::info);
54: luke.as(_Renderable_).renderTo("******** (luke as Renderable): %1$s %2$s ", log::info);
55: }
56: }
57: // END-SNIPPET: extensionmethod