Skip to content

Package: UserNotification

UserNotification

nameinstructionbranchcomplexitylinemethod
notification()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
withCaption(Class, String, Object[])
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
withCaption(String)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
withText(Class, String, Object[])
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
withText(String)
M: 0 C: 7
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: * SteelBlue: DCI User Interfaces
5: * http://tidalwave.it/projects/steelblue
6: *
7: * Copyright (C) 2015 - 2025 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/steelblue-src
22: * git clone https://github.com/tidalwave-it/steelblue-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.ui.core;
27:
28: import jakarta.annotation.Nonnull;
29: import javax.annotation.concurrent.Immutable;
30: import lombok.Getter;
31: import lombok.RequiredArgsConstructor;
32: import lombok.ToString;
33: import static it.tidalwave.util.BundleUtilities.getMessage;
34: import static lombok.AccessLevel.PROTECTED;
35:
36: /***************************************************************************************************************************************************************
37: *
38: * This class models a notification that will be presented to a user, without a feedback.
39: *
40: * @since 2.0-ALPHA-2
41: * @author Fabrizio Giudici
42: *
43: **************************************************************************************************************************************************************/
44: @Getter @Immutable
45: @RequiredArgsConstructor(access = PROTECTED) @ToString
46: public class UserNotification
47: {
48: @Nonnull
49: protected final String text;
50:
51: @Nonnull
52: protected final String caption;
53:
54: /***********************************************************************************************************************************************************
55: * {@return a notification with empty caption and text}.
56: **********************************************************************************************************************************************************/
57: @Nonnull
58: public static UserNotification notification()
59: {
60: return new UserNotification("", "");
61: }
62:
63: /***********************************************************************************************************************************************************
64: * {@return a notification with a caption}.
65: * @param caption the caption
66: **********************************************************************************************************************************************************/
67: @Nonnull
68: public UserNotification withCaption (@Nonnull final String caption)
69: {
70: return new UserNotification(text, caption);
71: }
72:
73: /***********************************************************************************************************************************************************
74: * {@return a notification with a caption from a bundle}.
75: * @param bundleClass the class where to search the resource bundle from
76: * @param resourceName the resource name of the caption in the bundle
77: * @param params some (optional) parameters to the resource
78: **********************************************************************************************************************************************************/
79: @Nonnull
80: public UserNotification withCaption (@Nonnull final Class<?> bundleClass, @Nonnull final String resourceName, @Nonnull final Object ... params)
81: {
82: return new UserNotification(text, getMessage(bundleClass, resourceName, params));
83: }
84:
85: /***********************************************************************************************************************************************************
86: * {@return a notification with a text}.
87: * @param text the text
88: **********************************************************************************************************************************************************/
89: @Nonnull
90: public UserNotification withText (@Nonnull final String text)
91: {
92: return new UserNotification(text, caption);
93: }
94:
95: /***********************************************************************************************************************************************************
96: * {@return a notification with a text from a bundle}.
97: * @param bundleClass the class where to search the resource bundle from
98: * @param resourceName the resource name of the text in the bundle
99: * @param params some (optional) parameters to the resource
100: **********************************************************************************************************************************************************/
101: @Nonnull
102: public UserNotification withText (@Nonnull final Class<?> bundleClass, @Nonnull final String resourceName, @Nonnull final Object ... params)
103: {
104: return new UserNotification(getMessage(bundleClass, resourceName, params), caption);
105: }
106: }