StepTypeConstants.java
package com.mycim.valueobject.prp;
import com.mycim.framework.utils.lang.StringUtils;
/**
* @author Qiansheng.Wang
* @since 2020-01-17
*/
public class StepTypeConstants {
/**
*
*/
public static final String PROCESSING_STEP_TYPE = "P";
public static final String STEP_TYPE_Y_KEY = "Y";
public static final String STEP_TYPE_M_KEY = "M";
public static final String STEP_TYPE_I_KEY = "I";
private StepTypeConstants() {
}
/**
* Convert measurement step type to processing step type according to mapping relationship
*
* <pre>
* StepTypeConst.convertMeasurementStepType(null) = "P"
* StepTypeConst.convertMeasurementStepType("") = "P"
* StepTypeConst.convertMeasurementStepType("P") = "P"
* StepTypeConst.convertMeasurementStepType("P1") = "P"
* StepTypeConst.convertMeasurementStepType("M") = "P"
* StepTypeConst.convertMeasurementStepType("M1") = "P1"
* StepTypeConst.convertMeasurementStepType("M2") = "P2"
* StepTypeConst.convertMeasurementStepType("MP1") = "P1"
* StepTypeConst.convertMeasurementStepType("MP2") = "P2"
* StepTypeConst.convertMeasurementStepType("Y") = "P"
* StepTypeConst.convertMeasurementStepType("Y1") = "P1"
* StepTypeConst.convertMeasurementStepType("Y2") = "P2"
* StepTypeConst.convertMeasurementStepType("YP1") = "P1"
* StepTypeConst.convertMeasurementStepType("YP2") = "P2"
* StepTypeConst.convertMeasurementStepType("I") = "P"
* StepTypeConst.convertMeasurementStepType("I1") = "P1"
* StepTypeConst.convertMeasurementStepType("I2") = "P2"
* StepTypeConst.convertMeasurementStepType("IP1") = "P1"
* StepTypeConst.convertMeasurementStepType("IP2") = "P2"
* </pre>
*
* @param measurementStepType Step Object Type
* @return
*/
public static String convertMeasurementStepType(String measurementStepType) {
String processingStepType = PROCESSING_STEP_TYPE;
if (StringUtils.length(measurementStepType) == 3 &&
StringUtils.contains(measurementStepType, PROCESSING_STEP_TYPE)) {
processingStepType = StringUtils
.substring(measurementStepType, StringUtils.lastIndexOf(measurementStepType, PROCESSING_STEP_TYPE),
measurementStepType.length());
}
if (StringUtils.length(measurementStepType) == 2) {
String seq = StringUtils.substring(measurementStepType, 1, 2);
processingStepType = PROCESSING_STEP_TYPE + seq;
}
return processingStepType;
}
/**
* @param stepType
* @return
*/
public static boolean isProcessingStep(String stepType) {
return StringUtils.startsWith(stepType, PROCESSING_STEP_TYPE);
}
/**
* @param stepType
* @return
*/
public static boolean isTypeP(String stepType) {
return StringUtils.equals(stepType, PROCESSING_STEP_TYPE);
}
/**
* @param stepType
* @return
*/
public static boolean isMeasurementStep(String stepType) {
return StringUtils.startsWith(stepType, STEP_TYPE_M_KEY);
}
public static boolean isTypeY(String stepType) {
return StringUtils.equals(stepType, STEP_TYPE_Y_KEY);
}
public static boolean isTypeM(String stepType) {
return StringUtils.equals(stepType, STEP_TYPE_M_KEY);
}
public static boolean isTypeYOrM(String stepType) {
return isTypeY(stepType) || isTypeM(stepType);
}
}