| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame; |
| | | |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.IRequestInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.FunctionCodeEnum; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/6 17:02 |
| | | * æå»ºä¸ä¸ªè¯·æ±å¸§ |
| | | */ |
| | | public class FrameBuilder { |
| | | |
| | | private IRequestFrame iRequestFrame; |
| | | private IRequestInnerFrame innerFrame; |
| | | |
| | | private String functionCode; |
| | | private String orderType; |
| | | |
| | | private FrameBuilder(String functionCode) { |
| | | this.functionCode = functionCode; |
| | | } |
| | | |
| | | public static FrameBuilder builderA1() { |
| | | return new FrameBuilder(FunctionCodeEnum.MAIN_BOARD_CONFIG.getCode()); |
| | | } |
| | | public static FrameBuilder builderA2() { |
| | | return new FrameBuilder(FunctionCodeEnum.MAIN_BOARD_CONTROL.getCode()); |
| | | } |
| | | |
| | | public static FrameBuilder builderA5() { |
| | | return new FrameBuilder(FunctionCodeEnum.DATA_TRANSPORT_DATA.getCode()); |
| | | } |
| | | |
| | | public FrameBuilder orderType(String orderType) { |
| | | this.orderType = orderType; |
| | | return this; |
| | | } |
| | | |
| | | public FrameBuilder innerFrame(IRequestInnerFrame innerFrame) { |
| | | this.innerFrame = innerFrame; |
| | | return this; |
| | | } |
| | | |
| | | public IRequestFrame build() { |
| | | if (orderType == null || innerFrame == null) { |
| | | throw new RuntimeException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (FunctionCodeEnum.MAIN_BOARD_CONFIG.getCode().equals(functionCode)) { |
| | | iRequestFrame = new A1Frame(orderType, innerFrame); |
| | | } else if (FunctionCodeEnum.MAIN_BOARD_CONTROL.getCode().equals(functionCode)) { |
| | | iRequestFrame = new A2Frame(orderType, innerFrame); |
| | | } else if (FunctionCodeEnum.DATA_TRANSPORT_DATA.getCode().equals(functionCode)) { |
| | | iRequestFrame = new A5Frame(orderType, innerFrame); |
| | | } else { |
| | | throw new RuntimeException("æ¾ä¸å°ç¬¦åæ¡ä»¶ç请æ±å¸§"); |
| | | } |
| | | return iRequestFrame; |
| | | } |
| | | } |