View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.common.rest.api.batch;
20  
21  import java.io.Serializable;
22  import java.util.List;
23  import java.util.Map;
24  import java.util.TreeMap;
25  import org.apache.commons.lang3.builder.EqualsBuilder;
26  import org.apache.commons.lang3.builder.HashCodeBuilder;
27  
28  public abstract class BatchItem implements Serializable {
29  
30      private static final long serialVersionUID = -1393976266651766259L;
31  
32      protected final Map<String, List<Object>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
33  
34      protected String content;
35  
36      public Map<String, List<Object>> getHeaders() {
37          return headers;
38      }
39  
40      public void setHeaders(final Map<String, List<Object>> headers) {
41          this.headers.clear();
42          this.headers.putAll(headers);
43      }
44  
45      public String getContent() {
46          return content;
47      }
48  
49      public void setContent(final String content) {
50          this.content = content;
51      }
52  
53      @Override
54      public int hashCode() {
55          return new HashCodeBuilder().
56                  appendSuper(super.hashCode()).
57                  append(headers).
58                  append(content).
59                  build();
60      }
61  
62      @Override
63      public boolean equals(final Object obj) {
64          if (this == obj) {
65              return true;
66          }
67          if (obj == null) {
68              return false;
69          }
70          if (getClass() != obj.getClass()) {
71              return false;
72          }
73          final BatchItem other = (BatchItem) obj;
74          return new EqualsBuilder().
75                  appendSuper(super.equals(obj)).
76                  append(headers, other.headers).
77                  append(content, other.content).
78                  build();
79      }
80  
81      @Override
82      public String toString() {
83          return "BatchItem{"
84                  + "headers=" + headers + ", "
85                  + "content=" + content
86                  + '}';
87      }
88  }