com.github.rrsunhome.excelsql.viewer.ViewerRegistry Maven / Gradle / Ivy
package com.github.rrsunhome.excelsql.viewer;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author : wangqijia
* create at: 2021/11/4 下午7:08
*/
public class ViewerRegistry {
protected final List viewers = new ArrayList<>();
public ViewerRegistry() {
addViewer(ConsoleViewer.INSTANCE);
}
/**
* @param viewer 展示层
*/
public void addViewer(Viewer viewer) {
if (viewer != null) {
this.viewers.add(viewer);
}
}
public void addViewers(List viewers) {
if (CollectionUtils.isNotEmpty(viewers)) {
this.viewers.addAll(viewers);
}
}
public void removeViewer(Viewer viewer) {
if (viewer != null) {
this.viewers.remove(viewer);
}
}
public List getViewers() {
return Collections.unmodifiableList(viewers);
}
}