1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.example.text.styling.parser; 17 18 import android.support.annotation.NonNull; 19 20 import java.util.List; 21 22 /** 23 * Markdown like type of element. 24 */ 25 public class Element { 26 27 public enum Type {TEXT, QUOTE, BULLET_POINT, CODE_BLOCK} 28 29 @NonNull 30 private final Type type; 31 32 @NonNull 33 private final String text; 34 35 @NonNull 36 private final List<Element> elements; 37 Element(@onNull final Type type, @NonNull final String text, @NonNull final List<Element> elements)38 public Element(@NonNull final Type type, @NonNull final String text, 39 @NonNull final List<Element> elements) { 40 this.type = type; 41 this.text = text; 42 this.elements = elements; 43 } 44 45 @NonNull getType()46 public Type getType() { 47 return type; 48 } 49 50 @NonNull getText()51 public String getText() { 52 return text; 53 } 54 55 @NonNull getElements()56 public List<Element> getElements() { 57 return elements; 58 } 59 60 @Override toString()61 public String toString() { 62 return type + " " + text; 63 } 64 } 65