public class MessageListItem extends Object implements Serializable
MessageList
.MessageList.setItems(Collection)
,
Serialized FormConstructor and Description |
---|
MessageListItem()
Creates an empty message list item.
|
MessageListItem(String text)
Creates a message list item with the provided text, which will be
displayed as plain text in the message body.
|
MessageListItem(String text,
Instant time,
String userName)
Creates a message list item with the provided text content, time and user
name.
|
MessageListItem(String text,
Instant time,
String userName,
String userImage)
Creates a message list item with the provided text content, time and user
name.
|
Modifier and Type | Method and Description |
---|---|
String |
getText()
Gets the text content of the message.
|
Instant |
getTime()
Gets the time of sending the message.
|
String |
getUserAbbreviation()
Gets the abbreviation of the message sender.
|
Integer |
getUserColorIndex()
Gets the color index of the message sender.
|
String |
getUserImage()
Gets the URL to the message sender's image.
|
AbstractStreamResource |
getUserImageResource()
Gets the image resource of the message sender's avatar.
|
String |
getUserName()
Gets the user name of the message sender.
|
void |
setText(String text)
Sets the text content of the message.
|
void |
setTime(Instant time)
Sets the time of sending the message.
|
void |
setUserAbbreviation(String userAbbreviation)
Sets the abbreviation of the message sender.
|
void |
setUserColorIndex(Integer userColorIndex)
Sets the color index of the message sender.
|
void |
setUserImage(String userImage)
Sets the URL to the message sender's image.
|
void |
setUserImageResource(AbstractStreamResource resource)
Sets the image for the message sender's avatar.
|
void |
setUserName(String userName)
Sets the user name of the message sender.
|
public MessageListItem()
public MessageListItem(String text)
text
- the text content of the messagesetText(String)
public MessageListItem(String text, Instant time, String userName)
The text will be rendered as plain text in the message body. The time and user name will also be displayed in the message component. The user name is also used in the message's avatar.
text
- the text content of the messagetime
- the time of sending the messageuserName
- the user name of the message sendersetText(String)
,
setTime(Instant)
,
setUserName(String)
public MessageListItem(String text, Instant time, String userName, String userImage)
The text will be rendered as plain text in the message body. The time and user name will also be displayed in the message component. The user image will be displayed in an avatar in the message.
text
- the text content of the messagetime
- the time of sending the messageuserName
- the user name of the message senderuserImage
- the URL of the message sender's imagesetText(String)
,
setTime(Instant)
,
setUserName(String)
,
setUserImage(String)
public String getText()
null
if none is setpublic void setText(String text)
text
- the message's text content to set, or null
to remove
the contentpublic Instant getTime()
null
if none is setpublic void setTime(Instant time)
time
- the time of the message to set, or null
to remove the
timepublic String getUserName()
null
if none is setpublic void setUserName(String userName)
In the avatar, the user name is presented in a tooltip on hover. It will
be also used to generate an abbreviation that is displayed as the avatar
content, when no setUserImage(String)
image} or
setUserAbbreviation(String)
abbreviation} is explicitly defined.
userName
- the message sender's user name, or null
to remove the
user namepublic String getUserAbbreviation()
null
if none is setpublic void setUserAbbreviation(String userAbbreviation)
setUserImage(String)
image} is
defined.userAbbreviation
- the message sender's abbreviation, or null
to remove
the abbreviationpublic String getUserImage()
If the image is set as a stream resource with
setUserImageResource(AbstractStreamResource)
,
this method will return a URL that is generated for that resource.
null
if none is
setpublic void setUserImage(String userImage)
Setting the image with this method resets the image resource provided
with setUserImageResource(AbstractStreamResource)
userImage
- the URL to the message sender's image, or null
to
remove the imagesetUserImageResource(AbstractStreamResource)
public Integer getUserColorIndex()
null
if none is setpublic void setUserColorIndex(Integer userColorIndex)
The color index defines which color will be used for the border of the
avatar. Color index N applies CSS variable --vaadin-user-color-N
to the border.
userColorIndex
- the color index to set, or null
to remove itpublic AbstractStreamResource getUserImageResource()
null
if the image has not
been set, or if the image is set with a URL by using
setUserImage(String)
public void setUserImageResource(AbstractStreamResource resource)
Setting the image as a resource with this method overrides the image URL
set with setUserImage(String)
.
resource
- the image resource, or null
to remove the resourcesetUserImage(String)
Copyright © 2025. All rights reserved.