Skip to content

Package: DefaultUserAction

DefaultUserAction

nameinstructionbranchcomplexitylinemethod
DefaultUserAction(As, Callback)
M: 30 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
DefaultUserAction(Callback, Collection)
M: 18 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
actionPerformed()
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
as(As.Type)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
as(Class)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
as(Class, As.NotFoundBehaviour)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
asMany(As.Type)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
asMany(Class)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
enabled()
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%
maybeAs(As.Type)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
maybeAs(Class)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
withCallback(As, Callback)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
withRoles(Collection)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * TheseFoolishThings: Miscellaneous utilities
5: * http://tidalwave.it/projects/thesefoolishthings
6: *
7: * Copyright (C) 2009 - 2023 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
12: * the License. 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
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/thesefoolishthings-src
23: * git clone https://github.com/tidalwave-it/thesefoolishthings-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.role.ui.impl;
28:
29: import javax.annotation.Nonnull;
30: import java.util.Collection;
31: import it.tidalwave.util.As;
32: import it.tidalwave.util.Callback;
33: import it.tidalwave.role.ui.BoundProperty;
34: import it.tidalwave.role.ui.UserAction;
35: import lombok.Getter;
36: import lombok.RequiredArgsConstructor;
37: import lombok.experimental.Accessors;
38: import lombok.experimental.Delegate;
39: import lombok.extern.slf4j.Slf4j;
40:
41: /***********************************************************************************************************************
42: *
43: * @author Fabrizio Giudici
44: *
45: **********************************************************************************************************************/
46:•@RequiredArgsConstructor(staticName = "withCallback") @Slf4j
47: public class DefaultUserAction implements UserAction
48: {
49: @Getter @Accessors(fluent = true)
50: private final BoundProperty<Boolean> enabled = new BoundProperty<>(true);
51:
52: @Delegate @Nonnull
53: private final As as;
54:
55: @Nonnull
56: private final Callback callback;
57:
58: /*******************************************************************************************************************
59: *
60: * @since 3.2-ALPHA-1 (was previously in {@code UserAction8}
61: * @since 3.2-ALPHA-3 (refactored)
62: *
63: ******************************************************************************************************************/
64: public DefaultUserAction (@Nonnull final Callback callback, @Nonnull final Collection<Object> roles)
65: {
66: this.callback = callback;
67: this.as = As.forObject(this, roles);
68: }
69:
70: /*******************************************************************************************************************
71: *
72: * @since 3.2-ALPHA-1 (was previously in {@code UserAction8}
73: * @since 3.2-ALPHA-3 (refactored)
74: *
75: ******************************************************************************************************************/
76: @Nonnull
77: public DefaultUserAction withRoles (@Nonnull final Collection<Object> roles)
78: {
79: return new DefaultUserAction(callback, roles);
80: }
81:
82: @Override
83: public void actionPerformed() // FIXME: change with composition
84: {
85: try
86: {
87: callback.call();
88: }
89: catch (Throwable e)
90: {
91: log.error("", e);
92: }
93: }
94: }