новый компонент: Text
This commit is contained in:
@@ -5,9 +5,11 @@ import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Accessors(fluent = true)
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
lombok.accessors.fluent=true
|
||||
46
protocol/src/main/java/mc/protocol/model/text/Text.java
Normal file
46
protocol/src/main/java/mc/protocol/model/text/Text.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package mc.protocol.model.text;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class Text {
|
||||
|
||||
public static final Text EMPTY = of("");
|
||||
|
||||
private String content;
|
||||
|
||||
Text(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static Text of(String content) {
|
||||
return new Text(content);
|
||||
}
|
||||
|
||||
public static Text.Builder builder() {
|
||||
return new Text.Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String content;
|
||||
|
||||
public Builder append(String content) {
|
||||
if (this.content == null) {
|
||||
this.content = content;
|
||||
} else {
|
||||
this.content += content;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Text build() {
|
||||
if (content == null) {
|
||||
return EMPTY;
|
||||
} else {
|
||||
return new Text(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user