001package org.apache.fulcrum.security.util; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.Collection; 023 024import org.apache.fulcrum.security.entity.Group; 025 026/** 027 * This class represents a set of Groups. It's useful for building 028 * administration UI. It enforces that only Group objects are allowed in the set 029 * and only relevant methods are available. 030 * 031 * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a> 032 * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a> 033 * @author <a href="mailto:marco@intermeta.de">Marco Knüttel</a> 034 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> 035 * @version $Id$ 036 */ 037public class GroupSet extends SecuritySet<Group> 038{ 039 /** 040 * Serial number 041 */ 042 private static final long serialVersionUID = 6882240173053961011L; 043 044 /** 045 * Constructs an empty GroupSet 046 */ 047 public GroupSet() 048 { 049 super(); 050 } 051 052 /** 053 * Constructs a new GroupSet with specified contents. 054 * 055 * If the given collection contains multiple objects that are identical WRT 056 * equals() method, some objects will be overwritten. 057 * 058 * @param groups 059 * A collection of groups to be contained in the set. 060 */ 061 public GroupSet(Collection<? extends Group> groups) 062 { 063 this(); 064 addAll(groups); 065 } 066 067 /** 068 * Returns a Group with the given name, if it is contained in this GroupSet. 069 * 070 * @param groupName 071 * Name of Group. 072 * @return Group if argument matched a Group in this GroupSet; null if no 073 * match. 074 * @deprecated Use getByName() 075 */ 076 @Deprecated 077 public Group getGroupByName(String groupName) 078 { 079 return getByName(groupName); 080 } 081 082 /** 083 * Returns a Group with the given id, if it is contained in this GroupSet. 084 * 085 * @param groupId 086 * Id of the group 087 * @return Group if argument matched a Group in this GroupSet; null if no 088 * match. 089 * @deprecated Use getById() 090 */ 091 @Deprecated 092 public Group getGroupById(Object groupId) 093 { 094 return getById(groupId); 095 } 096 097 /** 098 * Print out a GroupSet as a String 099 * 100 * @return The Group Set as String 101 * 102 */ 103 @Override 104 public String toString() 105 { 106 StringBuilder sb = new StringBuilder(); 107 sb.append("GroupSet: "); 108 sb.append(super.toString()); 109 110 return sb.toString(); 111 } 112}