public class PermissionHelper
extends java.lang.Object
| Constructor and Description |
|---|
PermissionHelper() |
| Modifier and Type | Method and Description |
|---|---|
static <T> java.util.Collection<T> |
applyAllowed(java.util.Collection<T> elements,
java.util.Collection<T> allowed)
Basically used for query filter semantics with collections, given a collection with the selected elements and another one with the allowed
elements:
If the allowed elements are empty, throws a
PermissionDeniedException. |
static <T> java.util.Set<T> |
applyAllowed(java.util.Set<T> elements,
java.util.Set<T> allowed)
Basically used for query filter semantics with collections, given a collection with the selected elements and another one with the allowed
elements:
If the allowed elements are empty, returns null.
|
static <T> void |
checkContains(java.util.Collection<? super T> allowed,
T element)
Throws a
PermissionDeniedException if allowed is empty or not contains the given element |
static void |
checkContainsId(java.util.Collection<? extends IEntity> entities,
java.lang.Long id)
Checks whether the given entity collection contains the given id
|
static void |
checkEquals(java.lang.Object expected,
java.lang.Object actual)
Throws a
PermissionDeniedException if expected is not the same as actual |
static void |
checkNotEmpty(java.util.Collection<?> collection)
Throws a
PermissionDeniedException if the given collection is empty |
static void |
checkNotNull(java.lang.Object object)
Throws a
PermissionDeniedException if the given object is null |
static <T> java.util.Collection<T> |
checkSelection(java.util.Collection<T> allowed,
java.util.Collection<T> selection)
Same as
checkSelection(Collection, Collection, boolean) but not supporting an empty collection for the allowed elements. |
static <T> java.util.Collection<T> |
checkSelection(java.util.Collection<T> allowed,
java.util.Collection<T> selection,
boolean isEmptyAllowedSupported)
Used for query filter semantics with collections.
Given a collection with the selected elements and another one with the allowed elements: If the allowed elements are empty (and empty for the allowed is not supported) it throws a PermissionDeniedException. |
public static <T> java.util.Collection<T> applyAllowed(java.util.Collection<T> elements,
java.util.Collection<T> allowed)
PermissionDeniedException.
If elements are empty, then allowed is returned.
Otherwise, returns elements.retainAll(allowed).public static <T> java.util.Set<T> applyAllowed(java.util.Set<T> elements,
java.util.Set<T> allowed)
public static <T> void checkContains(java.util.Collection<? super T> allowed,
T element)
PermissionDeniedException if allowed is empty or not contains the given elementpublic static void checkContainsId(java.util.Collection<? extends IEntity> entities, java.lang.Long id)
public static void checkEquals(java.lang.Object expected,
java.lang.Object actual)
PermissionDeniedException if expected is not the same as actualpublic static void checkNotEmpty(java.util.Collection<?> collection)
PermissionDeniedException if the given collection is emptypublic static void checkNotNull(java.lang.Object object)
PermissionDeniedException if the given object is nullpublic static <T> java.util.Collection<T> checkSelection(java.util.Collection<T> allowed,
java.util.Collection<T> selection)
checkSelection(Collection, Collection, boolean) but not supporting an empty collection for the allowed elements.public static <T> java.util.Collection<T> checkSelection(java.util.Collection<T> allowed,
java.util.Collection<T> selection,
boolean isEmptyAllowedSupported)