This project has retired. For details please refer to its Attic page.
AbstractPropertyData xref

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.chemistry.opencmis.commons.impl.dataobjects;
20  
21  import java.util.ArrayList;
22  import java.util.Collections;
23  import java.util.List;
24  
25  import org.apache.chemistry.opencmis.commons.data.PropertyData;
26  
27  /**
28   * Abstract property data implementation.
29   */
30  public abstract class AbstractPropertyData<T> extends AbstractExtensionData implements PropertyData<T> {
31  
32      private static final long serialVersionUID = 1L;
33  
34      private String id;
35      private String displayName;
36      private String localName;
37      private String queryName;
38  
39      private List<T> values;
40  
41      public String getId() {
42          return id;
43      }
44  
45      public void setId(String id) {
46          this.id = id;
47      }
48  
49      public String getDisplayName() {
50          return displayName;
51      }
52  
53      public void setDisplayName(String displayName) {
54          this.displayName = displayName;
55      }
56  
57      public String getLocalName() {
58          return localName;
59      }
60  
61      public void setLocalName(String localName) {
62          this.localName = localName;
63      }
64  
65      public String getQueryName() {
66          return queryName;
67      }
68  
69      public void setQueryName(String queryName) {
70          this.queryName = queryName;
71      }
72  
73      public List<T> getValues() {
74          return values;
75      }
76  
77      public void setValues(List<T> values) {
78          if (values == null) {
79              this.values = Collections.emptyList();
80          } else {
81              this.values = values;
82          }
83      }
84  
85      public void setValue(T value) {
86          if (value == null) {
87              values = Collections.emptyList();
88          } else {
89              values = new ArrayList<T>(1);
90              values.add(value);
91          }
92      }
93  
94      public T getFirstValue() {
95          if ((values != null) && (!values.isEmpty())) {
96              return values.get(0);
97          }
98  
99          return null;
100     }
101 
102     @Override
103     public String toString() {
104         return "Property [id=" + id + ", display Name=" + displayName + ", local name=" + localName + ", query name="
105                 + queryName + ", values=" + values + "]" + super.toString();
106     }
107 }