Add FormattedText addition

This commit is contained in:
altrisi committed 2020-12-14 18:36:24 +01:00
1 parent f859eb87b5
commit 7b77fb0853
1 file changed
+15
@@ -48,10 +48,25 @@ public class FormattedTextValue extends StringValue
return StringTag.of(Text.Serializer.toJson(text));
}
@Override
public Value add(Value o) {
if (o instanceof FormattedTextValue)
{
Text mergedText = ((BaseText) text).shallowCopy().append(((FormattedTextValue) o).getText());
return new FormattedTextValue(mergedText);
}
else
{
Text mergedText = ((BaseText) text).shallowCopy().append(o.getString());
return new FormattedTextValue(mergedText);
}
}
public String serialize()
{
return Text.Serializer.toJson(text);
}
public static FormattedTextValue deserialize(String serialized)
{
return new FormattedTextValue(Text.Serializer.fromJson(serialized));