org.sonar.api.notifications
Class Notification

java.lang.Object
  extended by org.sonar.api.notifications.Notification
All Implemented Interfaces:
Serializable

public class Notification
extends Object
implements Serializable

This class represents a notification that will be delivered to users. This is a general concept and it has no knowledge of the possible ways to be delivered (see NotificationChannel) or of the users who should receive it (see NotificationDispatcher).

When creating a new notification, it is strongly advised to give a default message that can be used by channels that don't want to specifically format messages for different notification types. You can use setDefaultMessage(String) for that purpose.

Since:
2.10
See Also:
Serialized Form

Constructor Summary
Notification(String type)
           Create a new Notification of the given type.
 
Method Summary
 boolean equals(Object obj)
           
 String getDefaultMessage()
          Returns the default message to display for this notification.
 String getFieldValue(String field)
          Returns the value of a field.
 String getType()
          Returns the type of the notification
 int hashCode()
           
 Notification setDefaultMessage(String value)
           When creating a new notification, it is strongly advised to give a default message that can be used by channels that don't want to specifically format messages for different notification types.
 Notification setFieldValue(String field, String value)
          Adds a field (kind of property) to the notification
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Notification

public Notification(String type)

Create a new Notification of the given type.

Example: type = "new-violations"

Parameters:
type - the type of notification
Method Detail

getType

public String getType()
Returns the type of the notification

Returns:
the type

setDefaultMessage

public Notification setDefaultMessage(String value)

When creating a new notification, it is strongly advised to give a default message that can be used by channels that don't want to specifically format messages for different notification types.

This method is equivalent to setting a value for the field DEFAULT_MESSAGE_KEY with setFieldValue(String, String).

Since:
3.5

getDefaultMessage

public String getDefaultMessage()
Returns the default message to display for this notification.


setFieldValue

public Notification setFieldValue(String field,
                                  @Nullable
                                  String value)
Adds a field (kind of property) to the notification

Parameters:
field - the name of the field (= the key)
value - the value of the field
Returns:
the notification itself

getFieldValue

@CheckForNull
public String getFieldValue(String field)
Returns the value of a field.

Parameters:
field - the field
Returns:
the value of the field

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2014 SonarSource. All Rights Reserved.