All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.digitalcollections.prosemirror.model.impl.contentblocks.TextImpl Maven / Gradle / Ivy

The newest version!
package de.digitalcollections.prosemirror.model.impl.contentblocks;

import de.digitalcollections.prosemirror.model.api.Mark;
import de.digitalcollections.prosemirror.model.api.contentblocks.Text;
import de.digitalcollections.prosemirror.model.impl.ContentBlockImpl;
import de.digitalcollections.prosemirror.model.impl.MarkImpl;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class TextImpl extends ContentBlockImpl implements Text {

  private String text;
  private List marks;

  public TextImpl() {}

  public TextImpl(String text) {
    this.text = text;
  }

  public TextImpl(String text, String... marks) {
    this(text);
    if (marks != null) {
      for (String markStr : marks) {
        Mark mark = new MarkImpl(markStr);
        addMark(mark);
      }
    }
  }

  @Override
  public String getText() {
    return text;
  }

  @Override
  public void setText(String text) {
    this.text = text;
  }

  @Override
  public List getMarks() {
    return marks;
  }

  @Override
  public void setMarks(List marks) {
    this.marks = marks;
  }

  @Override
  public void addMark(Mark mark) {
    if (marks == null) {
      marks = new ArrayList<>();
    }

    marks.add(mark);
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (!(o instanceof TextImpl)) {
      return false;
    }
    TextImpl text1 = (TextImpl) o;
    return Objects.equals(text, text1.text) && Objects.equals(marks, text1.marks);
  }

  @Override
  public int hashCode() {

    return Objects.hash(text, marks);
  }

  @Override
  public String toString() {
    return "TextImpl{"
        + "text='"
        + text
        + "\', "
        + "marks="
        + marks
        + ", "
        + "hashCode="
        + hashCode()
        + '}';
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy