View Javadoc
1   package emissary.client.response;
2   
3   import jakarta.annotation.Nullable;
4   import jakarta.xml.bind.annotation.XmlAccessOrder;
5   import jakarta.xml.bind.annotation.XmlAccessType;
6   import jakarta.xml.bind.annotation.XmlAccessorOrder;
7   import jakarta.xml.bind.annotation.XmlAccessorType;
8   import jakarta.xml.bind.annotation.XmlElement;
9   
10  import java.io.Serializable;
11  import java.util.HashSet;
12  import java.util.Set;
13  
14  @XmlAccessorType(XmlAccessType.NONE)
15  @XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
16  public class BaseResponseEntity implements Serializable, BaseEntity {
17  
18      private static final long serialVersionUID = 3432436269155177605L;
19  
20      @XmlElement(name = "errors")
21      private final Set<String> errors = new HashSet<>();
22  
23      @Override
24      public void addError(String error) {
25          errors.add(error);
26      }
27  
28      @Override
29      public Set<String> getErrors() {
30          return this.errors;
31      }
32  
33      @Override
34      public void append(BaseEntity entity) {
35          // This method is here so you consume a call from a peer
36          addErrors(entity.getErrors());
37      }
38  
39      protected void addErrors(@Nullable Set<String> errors) {
40          if (errors != null) {
41              for (String err : errors) {
42                  this.addError(err);
43              }
44          }
45      }
46  
47      @Override
48      public void dumpToConsole() {
49          // no-op
50      }
51  }