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

com.tw.go.plugin.cmd.InMemoryConsumer Maven / Gradle / Ivy

There is a newer version: 2.0
Show newest version
package com.tw.go.plugin.cmd;

import com.tw.go.plugin.util.ListUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

public class InMemoryConsumer implements StreamConsumer {
    private Queue lines = new ConcurrentLinkedQueue();

    public void consumeLine(String line) {
        try {
            lines.add(line);
        } catch (RuntimeException e) {
            // LOG.error("Problem consuming line [" + line + "]", e);
        }
    }

    public List asList() {
        return new ArrayList(lines);
    }

    public String toString() {
        return ListUtil.join(asList(), "\n");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy