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

com.aventstack.extentreports.markuputils.HtmlList Maven / Gradle / Ivy

There is a newer version: 5.1.2
Show newest version
package com.aventstack.extentreports.markuputils;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

abstract class HtmlList {
    @SuppressWarnings("unchecked")
    protected String getList(Object object, ListType listType) {
        final StringBuilder sb = new StringBuilder();
        sb.append("<" + listType.toString().toLowerCase() + ">");
        if (object instanceof Map) {
            for (Map.Entry entry : ((Map) object).entrySet()) {
                sb.append("
  • "); sb.append(entry.getKey()); sb.append(":"); sb.append(entry.getValue()); sb.append("
  • "); } } else if (object instanceof List || object instanceof Set || object.getClass().isArray()) { if (object.getClass().isArray()) object = Arrays.asList((Object[])object); for (Object o : (Collection) object) { sb.append("
  • "); sb.append(o.toString()); sb.append("
  • "); } } else { sb.append("
  • "); sb.append(object.toString()); sb.append("
  • "); } sb.append(""); return sb.toString(); } }