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

gu.sql2java.ListAction Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
package gu.sql2java;

import static com.google.common.base.Preconditions.checkNotNull;

import java.util.LinkedList;
import java.util.List;

import com.google.common.base.Function;

import gu.sql2java.pagehelper.Page;
import gu.sql2java.pagehelper.PageHelper;

/**
 * @author guyadong
 *
 * @param 
 * @since 3.18.3
 */
class ListAction implements TableManager.Action {
    final List list;
	public ListAction() {
		this(false);
    }
	/**
	 * @param nopage disable page helper if true
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
    public ListAction(boolean nopage) {
    	Page page;
    	if(!nopage && null != (page = PageHelper.getLocalPage()) && page.isEnable()){
    		list = page;
    	}else{
    		list = new LinkedList<>();
    	}
    }

    public List getList() {
        return list;
    }
    @SuppressWarnings("unchecked")
    public  List getList(Functiontransformer) {
        return PageHelper.transform(list,checkNotNull(transformer,"transformer is null"));
    }

    @Override
    public void call(B bean) {
        list.add(bean);
    }

}