001/**
002 *
003 * Copyright the original author or authors
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smackx.privacy;
018
019import org.jivesoftware.smackx.privacy.packet.PrivacyItem;
020
021import java.util.List;
022
023/**
024 * A privacy list represents a list of contacts that is a read only class used to represent a set of allowed or blocked communications. 
025 * Basically it can:<ul>
026 *
027 *      <li>Handle many {@link org.jivesoftware.smackx.privacy.packet.PrivacyItem}.</li>
028 *      <li>Answer if it is the default list.</li>
029 *      <li>Answer if it is the active list.</li>
030 * </ul>
031 *
032 * {@link PrivacyItem Privacy Items} can handle different kind of blocking communications based on JID, group,
033 * subscription type or globally.
034 * 
035 * @author Francisco Vives
036 */
037public class PrivacyList {
038
039    /** Holds if it is an active list or not **/
040    private final boolean isActiveList;
041    /** Holds if it is an default list or not **/
042    private final boolean isDefaultList;
043    /** Holds the list name used to print **/
044    private final String listName;
045    /** Holds the list of {@link PrivacyItem} */
046    private final List<PrivacyItem> items;
047    
048    protected PrivacyList(boolean isActiveList, boolean isDefaultList,
049            String listName, List<PrivacyItem> privacyItems) {
050        super();
051        this.isActiveList = isActiveList;
052        this.isDefaultList = isDefaultList;
053        this.listName = listName;
054        this.items = privacyItems;
055    }
056
057    public String getName() {
058        return listName;
059    }
060
061    public boolean isActiveList() {
062        return isActiveList;
063    }
064
065    public boolean isDefaultList() {
066        return isDefaultList;
067    }
068
069    public List<PrivacyItem> getItems() {
070        return items;
071    }
072
073    @Override
074    public String toString() {
075        return "Privacy List: " + listName + "(active:" + isActiveList + ", default:" + isDefaultList + ")";
076    }
077}