/** * Add a {@link Resource} to the collection of resources associated with this group. * <p/> * The implementation is synchronized, because it mutates the collection. * * @param resource {@link Resource} to add to this group (at the end). * @return the reference to Group (fluent interface). */ public Group addResource(final Resource resource) { notNull(resource); synchronized (this) { if (!hasResource(resource)) { resources.add(resource); } else { LOG.debug("Resource {} is already contained in this group, skipping it.", resource); } } return this; }
/** * Add a {@link Resource} to the collection of resources associated with this group. * <p/> * The implementation is synchronized, because it mutates the collection. * * @param resource * {@link Resource} to add to this group (at the end). * @return the reference to Group (fluent interface). */ public Group addResource(final Resource resource) { notNull(resource); synchronized (this) { if (!hasResource(resource)) { resources.add(resource); } else { LOG.debug("Resource {} is already contained in this group, skipping it.", resource); } } return this; }
/** * @param resource * the {@link Resource} to search in all available groups. * @return t collection of group names containing provided resource. If the resource is not availalbe, an empty collection * will be returned. */ public Collection<String> getGroupNamesContainingResource(final String resourceUri) { Validate.notNull(resourceUri); final Set<String> groupNames = new TreeSet<String>(); for (final Group group : map.values()) { if (group.hasResource(resourceUri)) { groupNames.add(group.getName()); } } return groupNames; }
/** * @param resource * the {@link Resource} to search in all available groups. * @return t collection of group names containing provided resource. If the resource is not availalbe, an empty collection * will be returned. */ public Collection<String> getGroupNamesContainingResource(final String resourceUri) { Validate.notNull(resourceUri); final Set<String> groupNames = new TreeSet<String>(); for (final Group group : map.values()) { if (group.hasResource(resourceUri)) { groupNames.add(group.getName()); } } return groupNames; }