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.ext.scimv2.api.data;
20  
21  import com.fasterxml.jackson.annotation.JsonCreator;
22  import com.fasterxml.jackson.annotation.JsonIgnore;
23  import com.fasterxml.jackson.annotation.JsonProperty;
24  import java.time.OffsetDateTime;
25  import java.util.Optional;
26  import javax.ws.rs.core.EntityTag;
27  import org.apache.syncope.ext.scimv2.api.type.Resource;
28  
29  public class Meta extends SCIMBean {
30  
31      private static final long serialVersionUID = 8976451652101091915L;
32  
33      private final Resource resourceType;
34  
35      private final OffsetDateTime created;
36  
37      private final OffsetDateTime lastModified;
38  
39      @JsonIgnore
40      private final EntityTag version;
41  
42      private final String location;
43  
44      @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
45      public Meta(
46              @JsonProperty("resourceType") final Resource resourceType,
47              @JsonProperty("created") final OffsetDateTime created,
48              @JsonProperty("lastModified") final OffsetDateTime lastModified,
49              @JsonProperty("version") final String version,
50              @JsonProperty("location") final String location) {
51  
52          this.resourceType = resourceType;
53          this.created = created;
54          this.lastModified = lastModified;
55          this.version = Optional.ofNullable(version).map(s -> new EntityTag(s, true)).orElse(null);
56          this.location = location;
57      }
58  
59      public Resource getResourceType() {
60          return resourceType;
61      }
62  
63      public OffsetDateTime getCreated() {
64          return created;
65      }
66  
67      public OffsetDateTime getLastModified() {
68          return lastModified;
69      }
70  
71      @JsonProperty
72      public String getVersion() {
73          return Optional.ofNullable(version).map(EntityTag::toString).orElse(null);
74      }
75  
76      public String getLocation() {
77          return location;
78      }
79  }