View Javadoc
1   /*
2    * #%L
3    * wcm.io
4    * %%
5    * Copyright (C) 2019 wcm.io
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package io.wcm.wcm.ui.granite.components.pathfield;
21  
22  import org.apache.sling.api.resource.Resource;
23  import org.osgi.annotation.versioning.ProviderType;
24  
25  /**
26   * Represents a column item in the column view.
27   */
28  @ProviderType
29  public final class ColumnItem {
30  
31    private final Resource resource;
32    private String resourceType;
33    private Boolean active;
34  
35    ColumnItem(Resource resource) {
36      this.resource = resource;
37    }
38  
39    /**
40     * Returns the resource associated with this column item.
41     * @return Resource of the column item
42     */
43    public Resource getResource() {
44      return this.resource;
45    }
46  
47    /**
48     * Returns the resource type of this column item.
49     * @return Resource type
50     */
51    public String getResourceType() {
52      return this.resourceType;
53    }
54  
55    ColumnItem resourceType(String value) {
56      this.resourceType = value;
57      return this;
58    }
59  
60    /**
61     * Indicates if this column item is active.
62     * @return true if active, false otherwise
63     */
64    public Boolean getActive() {
65      return this.active;
66    }
67  
68    ColumnItem active(Boolean value) {
69      this.active = value;
70      return this;
71    }
72  
73    /**
74     * Returns the item ID, which is the resource path.
75     * @return Item ID (resource path)
76     */
77    public String getItemId() {
78      return resource.getPath();
79    }
80  
81  }