Class SimpleUserNotification
- java.lang.Object
-
- org.silverpeas.core.notification.user.SimpleUserNotification
-
- All Implemented Interfaces:
UserNotification
public class SimpleUserNotification extends Object implements UserNotification
This implementation ofUserNotification
permits to send a simple user notification, basically a title and a message.It is also possible to deal with the
SilverpeasTemplate
API.This is useful when user notification must be performed into a simple functional context.
This implementation is designed in order to handle the messages into all the handled user languages
- Author:
- Yohann Chastagnier
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleUserNotification
andComponentInstanceId(String componentInstanceId)
Sets the instance id of the component from wich the notification is sent.SimpleUserNotification
andMessage(UnaryOperator<String> message)
Sets theUnaryOperator
which provides a message from a language.SimpleUserNotification
fillTemplate(Pair<String,String> path, BiConsumer<SilverpeasTemplate,String> template)
Sets theBiConsumer
which is filling theSilverpeasTemplate
data according to given language.SilverpeasTemplate
is initialized from given template path represented by aPair
.static SimpleUserNotification
from(User sender)
Initializes an instance by specifying directly the sender.static SimpleUserNotification
fromSystem()
Initializes an instance by indicating the system as the sender.NotificationMetaData
getNotificationMetaData()
Gets the metadata about the notification to send so that all the properties required to send the notification can be set.void
send()
Sends this notification at the specified addresses declared within the metadata of this notification.void
send(BuiltInNotifAddress notificationAddress)
Sends this notification to the specified builtin user notification address.SimpleUserNotification
toEMails(Stream<String> eMails, String language)
Sets the given e-mails as receivers.SimpleUserNotification
toGroups(Collection<Group> groups)
Sets the users of given groups as receivers.SimpleUserNotification
toGroups(Stream<Group> groups)
Sets the users of given groups as receivers.SimpleUserNotification
toGroups(Group... groups)
Sets the users of given groups as receivers.SimpleUserNotification
toUsers(Collection<User> users)
Sets the given users as receivers.SimpleUserNotification
toUsers(Stream<User> users)
Sets the given users as receivers.SimpleUserNotification
toUsers(User... users)
Sets the given users as receivers.SimpleUserNotification
withExtraMessage(String extraMessage)
Sets an extra message which is not produced against a language.SimpleUserNotification
withLink(Function<String,Link> link)
Sets theFunction
which provides a link from a language.SimpleUserNotification
withTitle(UnaryOperator<String> title)
Sets theUnaryOperator
which provides a title from a language.
-
-
-
Method Detail
-
fromSystem
public static SimpleUserNotification fromSystem()
Initializes an instance by indicating the system as the sender.- Returns:
- the new instance.
-
from
public static SimpleUserNotification from(User sender)
Initializes an instance by specifying directly the sender.- Parameters:
sender
- theUser
which represents the sender.- Returns:
- itself.
-
andComponentInstanceId
public SimpleUserNotification andComponentInstanceId(String componentInstanceId)
Sets the instance id of the component from wich the notification is sent.- Parameters:
componentInstanceId
- a component instance identifier as string.- Returns:
- itself.
-
withTitle
public SimpleUserNotification withTitle(UnaryOperator<String> title)
Sets theUnaryOperator
which provides a title from a language.- Parameters:
title
- aUnaryOperator
which provides a title by applying a language.- Returns:
- itself.
-
andMessage
public SimpleUserNotification andMessage(UnaryOperator<String> message)
Sets theUnaryOperator
which provides a message from a language.- Parameters:
message
- aUnaryOperator
which provides a message by applying a language.- Returns:
- itself.
-
withExtraMessage
public SimpleUserNotification withExtraMessage(String extraMessage)
Sets an extra message which is not produced against a language.- Parameters:
extraMessage
- an extra message as string.- Returns:
- itself.
-
fillTemplate
public SimpleUserNotification fillTemplate(Pair<String,String> path, BiConsumer<SilverpeasTemplate,String> template)
Sets theBiConsumer
which is filling theSilverpeasTemplate
data according to given language.SilverpeasTemplate
is initialized from given template path represented by aPair
.Messages supplied by
andMessage(UnaryOperator)
are provided to theSilverpeasTemplate
by${message}
variable.- Parameters:
path
- aPair
defining on the left the path and on the right the name of the aimed template.template
- aConsumer
which is filling theSilverpeasTemplate
data.- Returns:
- itself.
-
withLink
public SimpleUserNotification withLink(Function<String,Link> link)
Sets theFunction
which provides a link from a language.- Parameters:
link
- aFunction
which provides a message by applying a language.- Returns:
- itself.
-
toUsers
public SimpleUserNotification toUsers(Collection<User> users)
Sets the given users as receivers.- Parameters:
users
- the receivers represented by a list ofUser
.- Returns:
- itself.
-
toUsers
public SimpleUserNotification toUsers(User... users)
Sets the given users as receivers.- Parameters:
users
- the receivers represented by an array ofUser
.- Returns:
- itself.
-
toUsers
public SimpleUserNotification toUsers(Stream<User> users)
Sets the given users as receivers.- Parameters:
users
- the receivers represented by a stream ofUser
.- Returns:
- itself.
-
toGroups
public SimpleUserNotification toGroups(Collection<Group> groups)
Sets the users of given groups as receivers.- Parameters:
groups
- receivers represented by the users contained into the list ofGroup
.- Returns:
- itself.
-
toGroups
public SimpleUserNotification toGroups(Group... groups)
Sets the users of given groups as receivers.- Parameters:
groups
- receivers represented by the users contained into the array ofGroup
.- Returns:
- itself.
-
toGroups
public SimpleUserNotification toGroups(Stream<Group> groups)
Sets the users of given groups as receivers.- Parameters:
groups
- receivers represented by the users contained into the stream ofGroup
.- Returns:
- itself.
-
toEMails
public SimpleUserNotification toEMails(Stream<String> eMails, String language)
Sets the given e-mails as receivers.- Parameters:
eMails
- a stream of receiver e-mails.language
- the language to use with emails.- Returns:
- itself.
-
getNotificationMetaData
public NotificationMetaData getNotificationMetaData()
Description copied from interface:UserNotification
Gets the metadata about the notification to send so that all the properties required to send the notification can be set.- Specified by:
getNotificationMetaData
in interfaceUserNotification
- Returns:
- the notification metadata.
-
send
public void send()
Description copied from interface:UserNotification
Sends this notification at the specified addresses declared within the metadata of this notification.- Specified by:
send
in interfaceUserNotification
-
send
public void send(BuiltInNotifAddress notificationAddress)
Description copied from interface:UserNotification
Sends this notification to the specified builtin user notification address.- Specified by:
send
in interfaceUserNotification
- Parameters:
notificationAddress
- the type of the media to vehicle the notification.
-
-