
pl.bristleback.server.bristle.rights.ConnectorRightsSet Maven / Gradle / Ivy
// Bristleback plugin - Copyright (c) 2010 bristleback.googlecode.com
// ---------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
// This library is distributed in the hope that it will be useful,
// but without any warranty; without even the implied warranty of merchantability
// or fitness for a particular purpose.
// You should have received a copy of the GNU Lesser General Public License along
// with this program; if not, see .
// ---------------------------------------------------------------------------
package pl.bristleback.server.bristle.rights;
import org.apache.log4j.Logger;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* Wrapper class containing synchronized set of connector actual rights.
* All operations on this set are thread safe.
* New empty connector rights set is created automatically for every connector,
* and it is stored as a connector variable with a name given in
* {@link pl.bristleback.server.bristle.config.BristleConstants} class.
* For more useful methods using connector rights set, see {@link pl.bristleback.server.bristle.rights.ConnectorRightsUtil}.
*
* Created on: 2010-09-03 16:08:17
*
* @author Wojciech Niemiec
*/
public class ConnectorRightsSet {
private static Logger log = Logger.getLogger(ConnectorRightsSet.class.getName());
private Set rights;
/**
* Creates empty connector rights set.
*/
public ConnectorRightsSet() {
rights = Collections.synchronizedSet(new HashSet());
}
/**
* Adds right with given name. If right already existed in set, nothing happens.
*
* @param right name of the right.
*/
public void addRight(String right) {
rights.add(right);
}
/**
* Checks whether connector rights set contains all rights given in collection.
*
* @param rightsToCheck collection of checked rights.
* @return true if all rights from collection are in connector rights set.
*/
public boolean hasRights(Collection rightsToCheck) {
return rights.containsAll(rightsToCheck);
}
/**
* Checks whether set contains given right.
*
* @param right name of the right to check.
* @return true if set contains given right, false otherwise.
*/
public boolean hasRight(String right) {
return rights.contains(right);
}
/**
* Removes right given as a parameter. If set does not contains that right, nothing happens.
*
* @param right right to remove.
*/
public void removeRight(String right) {
rights.remove(right);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy