001/** 002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 003 * 004 * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved 005 * 006 * The contents of this file are subject to the terms 007 * of the Common Development and Distribution License 008 * (the License). You may not use this file except in 009 * compliance with the License. 010 * 011 * You can obtain a copy of the License at 012 * https://opensso.dev.java.net/public/CDDLv1.0.html or 013 * opensso/legal/CDDLv1.0.txt 014 * See the License for the specific language governing 015 * permission and limitations under the License. 016 * 017 * When distributing Covered Code, include this CDDL 018 * Header Notice in each file and include the License file 019 * at opensso/legal/CDDLv1.0.txt. 020 * If applicable, add the following below the CDDL Header, 021 * with the fields enclosed by brackets [] replaced by 022 * your own identifying information: 023 * "Portions Copyrighted [year] [name of copyright owner]" 024 * 025 * $Id: QualifiedCollection.java,v 1.3 2008/06/25 05:41:38 qcheng Exp $ 026 * 027 */ 028 029package com.iplanet.services.ldap.aci; 030 031import java.util.Collection; 032 033/** 034 * Class that wraps a collection and a boolean flag Used to represent ACI target 035 * attributes and ACI permissions. The boolean flag indicates whether the target 036 * attributes ( or the permissions ) are exclusive or inclusive 037 * @supported.api 038 */ 039public class QualifiedCollection { 040 041 Collection _collection; 042 043 boolean _exclusive; 044 045 /** 046 * Constructor 047 * 048 * @param collection 049 * the collections of values. 050 * @param exclusive 051 * the boolean flag indicating whether the values are excluisive 052 * or inclusive. 053 * @supported.api 054 */ 055 public QualifiedCollection(Collection collection, boolean exclusive) { 056 _collection = collection; 057 _exclusive = exclusive; 058 } 059 060 /** 061 * Compares whether the passed object is equal to this object semantically. 062 * The objects are considered equal if they have the same collection of 063 * values, and the same value of exclusive flag 064 * 065 * @param object 066 * the object that is to be compared for equality 067 * @return <code>true</code> if the passed object is equal to this object, 068 * <code>false</code> otherwise 069 * @supported.api 070 */ 071 public boolean equals(Object object) { 072 boolean objectsEqual = false; 073 if (object == this) { 074 objectsEqual = true; 075 } else if (object != null && object.getClass().equals(getClass())) { 076 QualifiedCollection castObject = (QualifiedCollection) object; 077 if ((castObject.isExclusive() == isExclusive()) 078 && (castObject.getCollection().equals(getCollection()))) { 079 objectsEqual = true; 080 } 081 } 082 return objectsEqual; 083 } 084 085 /** 086 * Clones this object 087 * 088 * @return the cloned object 089 * @supported.api 090 */ 091 public Object clone() { 092 QualifiedCollection theClone = null; 093 try { 094 theClone = (QualifiedCollection) super.clone(); 095 } catch (CloneNotSupportedException ingnored) { 096 } 097 if (theClone != null) { 098 theClone.setCollection(getCollection()); 099 theClone.setExclusive(isExclusive()); 100 } 101 return theClone; 102 } 103 104 /** 105 * Sets the collection of values 106 * 107 * @param collection 108 * the collection of values 109 * @supported.api 110 */ 111 public void setCollection(Collection collection) { 112 _collection = collection; 113 } 114 115 /** 116 * Gets the collection of values 117 * 118 * @return the collection of values 119 * @supported.api 120 */ 121 public Collection getCollection() { 122 return _collection; 123 } 124 125 /** 126 * Sets the exclusive flag 127 * 128 * @param exclusive 129 * value of exclusive flag 130 * @supported.api 131 */ 132 public void setExclusive(boolean exclusive) { 133 _exclusive = exclusive; 134 } 135 136 /** 137 * Gets the value of the exclusive flag 138 * 139 * @return the value of the exclusive flag 140 * @supported.api 141 */ 142 public boolean isExclusive() { 143 return _exclusive; 144 } 145}
Copyright © 2010-2017, ForgeRock All Rights Reserved.