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.lib.to;
20  
21  import io.swagger.v3.oas.annotations.media.Schema;
22  import java.time.OffsetDateTime;
23  import org.apache.commons.lang3.builder.EqualsBuilder;
24  import org.apache.commons.lang3.builder.HashCodeBuilder;
25  import org.apache.commons.lang3.builder.ToStringBuilder;
26  import org.apache.commons.lang3.builder.ToStringStyle;
27  import org.apache.syncope.common.lib.BaseBean;
28  
29  public class AbstractStartEndBean implements BaseBean {
30  
31      private static final long serialVersionUID = 2399577415544539917L;
32  
33      private OffsetDateTime start;
34  
35      private OffsetDateTime end;
36  
37      @Schema(accessMode = Schema.AccessMode.READ_ONLY)
38      public OffsetDateTime getStart() {
39          return start;
40      }
41  
42      public void setStart(final OffsetDateTime start) {
43          this.start = start;
44      }
45  
46      @Schema(accessMode = Schema.AccessMode.READ_ONLY)
47      public OffsetDateTime getEnd() {
48          return end;
49      }
50  
51      public void setEnd(final OffsetDateTime end) {
52          this.end = end;
53      }
54  
55      @Override
56      public int hashCode() {
57          return new HashCodeBuilder().
58                  append(start).
59                  append(end).
60                  build();
61      }
62  
63      @Override
64      public boolean equals(final Object obj) {
65          if (this == obj) {
66              return true;
67          }
68          if (obj == null) {
69              return false;
70          }
71          if (getClass() != obj.getClass()) {
72              return false;
73          }
74          final AbstractStartEndBean other = (AbstractStartEndBean) obj;
75          return new EqualsBuilder().
76                  append(start, other.start).
77                  append(end, other.end).
78                  build();
79      }
80  
81      @Override
82      public String toString() {
83          return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).
84                  append(start).
85                  append(end).
86                  build();
87      }
88  }