001/* 002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Anahide Tchertchian 016 */ 017package org.nuxeo.ecm.platform.query.api; 018 019import java.util.ArrayList; 020import java.util.Collection; 021import java.util.List; 022 023/** 024 * List of {@link PageSelection} elements. 025 * 026 * @author Anahide Tchertchian 027 */ 028public class PageSelections<T> { 029 030 protected String name; 031 032 protected boolean selected; 033 034 protected List<PageSelection<T>> entries; 035 036 public PageSelections() { 037 super(); 038 } 039 040 public PageSelections(Collection<? extends PageSelection<T>> c) { 041 super(); 042 if (c != null) { 043 this.entries = new ArrayList<PageSelection<T>>(c); 044 } 045 } 046 047 public void setName(String name) { 048 this.name = name; 049 } 050 051 public String getName() { 052 return name; 053 } 054 055 public void setSelected(boolean selected) { 056 this.selected = selected; 057 if (entries != null) { 058 for (PageSelection<T> item : entries) { 059 item.setSelected(selected); 060 } 061 } 062 } 063 064 public boolean isSelected() { 065 return selected; 066 } 067 068 public List<PageSelection<T>> getEntries() { 069 return entries; 070 } 071 072 public void setEntries(List<PageSelection<T>> entries) { 073 this.entries = entries; 074 } 075 076 /** 077 * @since 6.0 078 */ 079 public void add(PageSelection<T> entry) { 080 if (entries == null) { 081 entries = new ArrayList<>(); 082 } 083 entries.add(entry); 084 } 085 086 public int getSize() { 087 if (entries == null) { 088 return 0; 089 } else { 090 return entries.size(); 091 } 092 } 093 094 /** 095 * @deprecated just here for compatibility with SelectDatamodel methods, use {@link #getSize()} instead 096 */ 097 @Deprecated 098 public int getRowCount() { 099 return getSize(); 100 } 101 102 /** 103 * @deprecated just here for compatibility with SelectDatamodel methods, use {@link #getEntries()} instead 104 */ 105 @Deprecated 106 public List<PageSelection<T>> getRows() { 107 return getEntries(); 108 } 109 110 /** 111 * @since 7.4 112 */ 113 public boolean isEmpty() { 114 return getSize() == 0; 115 } 116}