package com.swfarm.biz.chain.bo;

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

public class RefundProcessSteps {

	public static Integer CODE = 0;

	public static Integer NAME = 1;

	public static Integer STEP_START = 0;

	public static Integer STEP_SUBMIT = 1;

	public static Integer STEP_REFUND = 2;

	public static Integer STEP_REJECT = 3;

	public static Integer STEP_CANCEL = 4;

	private static String[][] steps = new String[][] {
		new String[] { "Start", "请求退款" },
		new String[] { "Submit", "提交退款" },
		new String[] { "Refund", "完成退款" },
		new String[] { "Reject", "退回修改" },
		new String[] { "Cancel", "取消退款" } };

	public static int getStepIndex(String stepName) {
		for (int i = 0; i < steps.length; i++) {
			String[] step = steps[i];
			if (step[0].equals(stepName)) {
				return i;
			}
		}
		return 0;
	}

	public static String[] getFirstStep() {
		return steps[0];
	}

	public static String[] getLastStep() {
		return steps[steps.length - 1];
	}

	public static String[] getStep(int index) {
		return steps[index];
	}

	public static String[] getStepByName(String name) {
		int index = getStepIndex(name);
		return steps[index];
	}

	public static String[] getNextStep(String stepName) {
		int index = getStepIndex(stepName);
		if (index < steps.length - 1) {
			return getStep(index + 1);
		} else {
			return null;
		}
	}

	public static String[][] getSteps() {
		return steps;
	}

	public static List<NameValuePair> getStepPairs() {
		List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
		for (int i = 0; i < steps.length; i++) {
			NameValuePair nameValuePair = new NameValuePair();
			nameValuePair.setKey(steps[i][0]);
			nameValuePair.setValue(steps[i][1]);
			nameValuePairs.add(nameValuePair);
		}
		return nameValuePairs;
	}

	public static int compareStep(String step1, String step2) {
		int stepIndex1 = getStepIndex(step1);
		int stepIndex2 = getStepIndex(step2);
		if (stepIndex1 > stepIndex2) {
			return 1;
		} else if (stepIndex1 == stepIndex2) {
			return 0;
		} else {
			return -1;
		}
	}

	public static void main(String[] args) {
	}
}
