Package: UserNotification
UserNotification
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
UserNotification(String, String) |
|
|
|
|
|
||||||||||||||||||||
getCaption() |
|
|
|
|
|
||||||||||||||||||||
getText() |
|
|
|
|
|
||||||||||||||||||||
notification() |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
||||||||||||||||||||
withCaption(Class, String, Object[]) |
|
|
|
|
|
||||||||||||||||||||
withCaption(String) |
|
|
|
|
|
||||||||||||||||||||
withText(Class, String, Object[]) |
|
|
|
|
|
||||||||||||||||||||
withText(String) |
|
|
|
|
|
Coverage
1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * These Foolish Things - Miscellaneous utilities
6: * http://thesefoolishthings.tidalwave.it - git clone git@bitbucket.org:tidalwave/thesefoolishthings-src.git
7: * %%
8: * Copyright (C) 2009 - 2018 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: * $Id$
24: *
25: * *********************************************************************************************************************
26: * #L%
27: */
28: package it.tidalwave.util.ui;
29:
30: import javax.annotation.Nonnull;
31: import javax.annotation.concurrent.Immutable;
32: import lombok.Getter;
33: import lombok.RequiredArgsConstructor;
34: import lombok.ToString;
35: import static it.tidalwave.util.BundleUtilities.getMessage;
36: import static lombok.AccessLevel.PROTECTED;
37:
38: /***********************************************************************************************************************
39: *
40: * @author Fabrizio Giudici
41: * @version $Id$
42: *
43: **********************************************************************************************************************/
44: @Immutable
45: @RequiredArgsConstructor(access = PROTECTED) @ToString
46: public class UserNotification
47: {
48: @Getter
49: protected final String text;
50:
51: @Getter
52: protected final String caption;
53:
54: /*******************************************************************************************************************
55: *
56: * Creates a notification with empty caption and text.
57: *
58: * @return the notification
59: *
60: ******************************************************************************************************************/
61: @Nonnull
62: public static UserNotification notification()
63: {
64: return new UserNotification("", "");
65: }
66:
67: /*******************************************************************************************************************
68: *
69: * Associates a caption to the notification.
70: *
71: * @param caption the caption
72: * @return the notification
73: *
74: ******************************************************************************************************************/
75: @Nonnull
76: public UserNotification withCaption (final @Nonnull String caption)
77: {
78: return new UserNotification(text, caption);
79: }
80:
81: /*******************************************************************************************************************
82: *
83: * Associates a caption to the notification, retrieved from a resource bundle.
84: *
85: * @param bundleClass the class where to search the resource bundle from
86: * @param resourceName the resource name of the caption in the bundle
87: * @param params some (optional) parameters to the resource
88: * @return the notification
89: *
90: ******************************************************************************************************************/
91: @Nonnull
92: public UserNotification withCaption (final @Nonnull Class<?> bundleClass,
93: final @Nonnull String resourceName,
94: final @Nonnull Object ... params)
95: {
96: return new UserNotification(text, getMessage(bundleClass, resourceName, params));
97: }
98:
99: /*******************************************************************************************************************
100: *
101: * Associates a text to the notification.
102: *
103: * @param text the text
104: * @return the notification
105: *
106: ******************************************************************************************************************/
107: @Nonnull
108: public UserNotification withText (final @Nonnull String text)
109: {
110: return new UserNotification(text, caption);
111: }
112:
113: /*******************************************************************************************************************
114: *
115: * Associates a text to the notification, retrieved from a resource bundle.
116: *
117: * @param bundleClass the class where to search the resource bundle from
118: * @param resourceName the resource name of the text in the bundle
119: * @param params some (optional) parameters to the resource
120: * @return the notification
121: *
122: ******************************************************************************************************************/
123: @Nonnull
124: public UserNotification withText (final @Nonnull Class<?> bundleClass,
125: final @Nonnull String resourceName,
126: final @Nonnull Object ... params)
127: {
128: return new UserNotification(getMessage(bundleClass, resourceName, params), caption);
129: }
130: }