ErrorCodeVO.java

  1. /*
  2.  * Copyright 2005-2025 the original author or authors.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  * http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16. package org.openwms.common.location.api;

  17. import com.fasterxml.jackson.annotation.JsonInclude;
  18. import com.fasterxml.jackson.annotation.JsonProperty;

  19. import java.io.Serializable;
  20. import java.util.Objects;

  21. /**
  22.  * A ErrorCodeVO.
  23.  *
  24.  * @author Heiko Scherrer
  25.  */
  26. @JsonInclude(JsonInclude.Include.NON_EMPTY)
  27. public class ErrorCodeVO implements Serializable {

  28.     public static final String ALL_NOT_SET = "********";
  29.     public static final int STATE_IN_POSITION = ALL_NOT_SET.length()-1;
  30.     public static final int STATE_OUT_POSITION = ALL_NOT_SET.length()-2;

  31.     public static final ErrorCodeVO LOCK_STATE_IN = new ErrorCodeVO("*******1");
  32.     public static final ErrorCodeVO UNLOCK_STATE_IN = new ErrorCodeVO("*******0");
  33.     public static final ErrorCodeVO LOCK_STATE_OUT = new ErrorCodeVO("******1*");
  34.     public static final ErrorCodeVO UNLOCK_STATE_OUT = new ErrorCodeVO("******0*");
  35.     public static final ErrorCodeVO LOCK_STATE_IN_AND_OUT = new ErrorCodeVO("******11");
  36.     public static final ErrorCodeVO UNLOCK_STATE_IN_AND_OUT = new ErrorCodeVO("******00");

  37.     @JsonProperty("errorCode")
  38.     private String errorCode = ErrorCodeVO.ALL_NOT_SET;
  39.     @JsonProperty("plcState")
  40.     private Integer plcState;

  41.     public ErrorCodeVO() {
  42.     }

  43.     public ErrorCodeVO(String errorCode) {
  44.         this.errorCode = errorCode;
  45.     }

  46.     public ErrorCodeVO(int plcState) {
  47.         this.plcState = plcState;
  48.     }

  49.     public ErrorCodeVO(String errorCode, int plcState) {
  50.         this.errorCode = errorCode;
  51.         this.plcState = plcState;
  52.     }

  53.     public String getErrorCode() {
  54.         return errorCode;
  55.     }

  56.     public void setErrorCode(String errorCode) {
  57.         this.errorCode = errorCode;
  58.     }

  59.     public Integer getPlcState() {
  60.         return plcState;
  61.     }

  62.     public void setPlcState(Integer plcState) {
  63.         this.plcState = plcState;
  64.     }

  65.     @Override
  66.     public boolean equals(Object o) {
  67.         if (this == o) return true;
  68.         if (o == null || getClass() != o.getClass()) return false;
  69.         ErrorCodeVO that = (ErrorCodeVO) o;
  70.         return Objects.equals(errorCode, that.errorCode) &&
  71.                 Objects.equals(plcState, that.plcState);
  72.     }

  73.     @Override
  74.     public int hashCode() {
  75.         return Objects.hash(errorCode, plcState);
  76.     }
  77. }