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

com.contentful.java.cda.rich.CDARichText Maven / Gradle / Ivy

There is a newer version: 9.1.0
Show newest version
package com.contentful.java.cda.rich;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * A leaf element of the rich text node graph: Render a given text with the given markings.
 */
public class CDARichText extends CDARichNode implements Serializable {
  private final List marks = new ArrayList<>();
  private final CharSequence text;

  /**
   * Create a text with the given marks
   *
   * @param text  the text to be displayed
   * @param marks the marks to be used if any
   */
  public CDARichText(CharSequence text, List marks) {
    if (text == null) {
      text = "";
    }

    this.marks.addAll(marks);
    this.text = text;
  }

  /**
   * @return the text of this node.
   */
  public CharSequence getText() {
    return text;
  }

  /**
   * @return the marks of this text.
   *
   * @see CDARichMark.CDARichMarkBold
   */
  public List getMarks() {
    return marks;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy