package com.uas.platform.b2b.event;

import org.springframework.context.ApplicationEvent;

import java.util.ArrayList;
import java.util.List;


/**
 * 新增消息事件
 * 
 * @param <S>
 *            生成的消息记录
 * @param <T>
 *            原单据
 * 
 * @author yingp
 * 
 */
public abstract class SaveReleaseEvent<S, T> extends ApplicationEvent {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	private List<T> savedList;

	public SaveReleaseEvent(List<T> savedList) {
		super(savedList);
		this.savedList = savedList;
	}

	/**
	 *
	 *
	 * @return
	 */
	public final List<S> release() {
		List<S> releaseList = new ArrayList<S>();
		for (T saved : savedList) {
            releaseList.add(release(saved));
        }
		return releaseList;
	}

	/**
	 * 生成对应消息记录
	 * 
	 * @param saved
	 * @return
	 */
	public abstract S release(T saved);

}
