package cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.isRedWriteOff.context;

import cn.superdesk.uniorder.common.enums.invoice.InvoiceInvoicedIsRedWriteOffEnum;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.invoice.customer.invoiced.InvoiceInvoiced;
import cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.isRedWriteOff.state.InvoiceInvoicedFieldIsRedWriteOffState;
import cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.isRedWriteOff.state.concrete.InvoiceInvoicedFieldIsRedWriteOffConcreteState_0_否;
import cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.isRedWriteOff.state.concrete.InvoiceInvoicedFieldIsRedWriteOffConcreteState_1_是;
import lombok.Data;

/**
 * @Description: 简易状态机 星型结构
 * @Author: linjinyu
 * @CreateDate: 10/12/20 4:28 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 10/12/20 4:28 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Data
public class InvoiceInvoicedFieldIsRedWriteOffContext {

	private InvoiceInvoicedFieldIsRedWriteOffState state_0_否;
	private InvoiceInvoicedFieldIsRedWriteOffState state_1_是;

	private InvoiceInvoicedFieldIsRedWriteOffState state;

	private InvoiceInvoiced entity;

	private LoginSysUser loginSysUser;


	public InvoiceInvoicedFieldIsRedWriteOffContext(InvoiceInvoiced entity, LoginSysUser loginSysUser) {

		this.state_0_否 = new InvoiceInvoicedFieldIsRedWriteOffConcreteState_0_否(this);
		this.state_1_是 = new InvoiceInvoicedFieldIsRedWriteOffConcreteState_1_是(this);


		this.entity = entity;
		this.loginSysUser = loginSysUser;

		switch (InvoiceInvoicedIsRedWriteOffEnum.get(this.entity.getIsRedWriteOff())) {

			case 否:
				state = state_0_否;
				break;
			case 是:
				state = state_1_是;
				break;

			default:
//				state = state_0_否;
				break;

		}
	}

	// 否(0, "否"),
	public void opInit() {
		state.opInit();
	}

	// 是(1, "是"),
	public void opRedWriteOff() {
		state.opRedWriteOff();
	}


	@Override
	public String toString() {
		return "状态 :" + getState().getClass().getName();
	}
}
