ColumnItem.java

  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. import org.apache.sling.api.resource.Resource;
  22. import org.osgi.annotation.versioning.ProviderType;

  23. /**
  24.  * Represents a column item in the column view.
  25.  */
  26. @ProviderType
  27. public final class ColumnItem {

  28.   private final Resource resource;
  29.   private String resourceType;
  30.   private Boolean active;

  31.   ColumnItem(Resource resource) {
  32.     this.resource = resource;
  33.   }

  34.   /**
  35.    * Returns the resource associated with this column item.
  36.    * @return Resource of the column item
  37.    */
  38.   public Resource getResource() {
  39.     return this.resource;
  40.   }

  41.   /**
  42.    * Returns the resource type of this column item.
  43.    * @return Resource type
  44.    */
  45.   public String getResourceType() {
  46.     return this.resourceType;
  47.   }

  48.   ColumnItem resourceType(String value) {
  49.     this.resourceType = value;
  50.     return this;
  51.   }

  52.   /**
  53.    * Indicates if this column item is active.
  54.    * @return true if active, false otherwise
  55.    */
  56.   public Boolean getActive() {
  57.     return this.active;
  58.   }

  59.   ColumnItem active(Boolean value) {
  60.     this.active = value;
  61.     return this;
  62.   }

  63.   /**
  64.    * Returns the item ID, which is the resource path.
  65.    * @return Item ID (resource path)
  66.    */
  67.   public String getItemId() {
  68.     return resource.getPath();
  69.   }

  70. }