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 java.util.ArrayList;
23  import java.util.Collections;
24  import java.util.List;
25  
26  import org.osgi.annotation.versioning.ProviderType;
27  
28  /**
29   * Represents a column in the column view.
30   */
31  @ProviderType
32  public final class Column {
33  
34    private String columnId;
35    private boolean hasMore;
36    private boolean lazy;
37    private boolean isCurrentResource;
38    private String activeId;
39    private boolean metaElement;
40    private final List<ColumnItem> items = new ArrayList<>();
41  
42    Column() {
43      // non-public constructor
44    }
45  
46    /**
47     * Returns the column ID.
48     * @return Column ID
49     */
50    public String getColumnId() {
51      return this.columnId;
52    }
53  
54    Column columnId(String value) {
55      this.columnId = value;
56      return this;
57    }
58  
59    /**
60     * Indicates if there are more items in the column.
61     * @return true if there are more items, false otherwise
62     */
63    public boolean isHasMore() {
64      return this.hasMore;
65    }
66  
67    Column hasMore(boolean value) {
68      this.hasMore = value;
69      return this;
70    }
71  
72    /**
73     * Indicates if the column is loaded lazily.
74     * @return true if lazy loading is enabled, false otherwise
75     */
76    public boolean isLazy() {
77      return this.lazy;
78    }
79  
80    Column lazy(boolean value) {
81      this.lazy = value;
82      return this;
83    }
84  
85    /**
86     * Indicates if this column represents the current resource.
87     * @return true if current resource, false otherwise
88     */
89    public boolean isCurrentResource() {
90      return this.isCurrentResource;
91    }
92  
93    Column isCurrentResource(boolean value) {
94      this.isCurrentResource = value;
95      return this;
96    }
97  
98    /**
99     * Returns the active item ID in the column.
100    * @return Active item ID
101    */
102   public String getActiveId() {
103     return this.activeId;
104   }
105 
106   Column activeId(String value) {
107     this.activeId = value;
108     return this;
109   }
110 
111   /**
112    * Indicates if this column is a meta element.
113    * @return true if meta element, false otherwise
114    */
115   public boolean isMetaElement() {
116     return this.metaElement;
117   }
118 
119   Column metaElement(boolean value) {
120     this.metaElement = value;
121     return this;
122   }
123 
124   void addItem(ColumnItem item) {
125     this.items.add(item);
126   }
127 
128   /**
129    * Returns the list of items in the column.
130    * @return List of column items
131    */
132   public List<ColumnItem> getItems() {
133     return Collections.unmodifiableList(this.items);
134   }
135 
136 }