Package com.easydesk.security.util
Class SecuritySet<K,T extends SecurityEntity<K>>
java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractSet<T>
com.easydesk.security.util.SecuritySet<K,T>
- Type Parameters:
K- entity 의 id type (Comparable 이어야 한다)T- SecurityEntity type
- All Implemented Interfaces:
Serializable,Iterable<T>,Collection<T>,Set<T>
- Direct Known Subclasses:
GroupSet,PermissionSet,RoleSet,UserSet
public abstract class SecuritySet<K,T extends SecurityEntity<K>>
extends AbstractSet<T>
implements Serializable
SecurityEntity 를 id 와 name 으로 관리하는 Set.
id 와 name(대소문자 구분 없음) 두 개의 map 을 동기화하여 유지하며, id 가 없거나 id 또는 name 이 이미 존재하는 entity 는 추가하지 않는다. 순회 순서는 id 순서이다.
- Author:
- Youngho Cho
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanentity 를 추가한다. id 가 없거나 id 또는 name 이 이미 존재하면 추가하지 않는다.voidclear()booleanid 가 같은 entity 가 있는지 확인한다.final boolean전달된 모든 요소가 Set에 포함되어 있는지 확인합니다.final booleancontainsAll(T... tArray) 전달된 모든 요소가 Set 에 포함되어 있는지 확인합니다.booleancontainsId(K id) id 에 해당하는 entity 가 있는지 확인한다.booleancontainsName(String name) 이름(대소문자 구분 없음)에 해당하는 entity 가 있는지 확인한다.id 에 해당하는 entity 를 구한다.이름(대소문자 구분 없음)에 해당하는 entity 를 구한다.getIds()Returns an unmodifiable view of the ids in this set.getNames()Returns an unmodifiable view of the names in this set.getSet()Returns an unmodifiable snapshot of the entities in this set.iterator()booleanid 가 같은 entity 를 제거한다.intsize()toString()Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
addAll, containsAll, isEmpty, retainAll, spliterator, toArray, toArray
-
Field Details
-
nameMap
Map for "name" -> "security object" -
idMap
Map for "id" -> "security object" Key 는 comparable 을 구현해야 한다.
-
-
Constructor Details
-
SecuritySet
protected SecuritySet()하위 클래스에서 사용하는 기본 생성자.
-
-
Method Details
-
getSet
Returns an unmodifiable snapshot of the entities in this set.- Returns:
- entity 들의 변경 불가능한 복사본
-
getNames
Returns an unmodifiable view of the names in this set.- Returns:
- name 들의 변경 불가능한 view
-
getIds
Returns an unmodifiable view of the ids in this set.- Returns:
- id 들의 변경 불가능한 view
-
clear
public void clear()- Specified by:
clearin interfaceCollection<K>- Specified by:
clearin interfaceSet<K>- Overrides:
clearin classAbstractCollection<T extends SecurityEntity<K>>
-
containsName
이름(대소문자 구분 없음)에 해당하는 entity 가 있는지 확인한다.- Parameters:
name- 확인할 이름- Returns:
- 있으면
true, 이름이 비어 있으면false
-
containsId
id 에 해당하는 entity 가 있는지 확인한다.- Parameters:
id- 확인할 id- Returns:
- 있으면
true
-
iterator
- Specified by:
iteratorin interfaceCollection<K>- Specified by:
iteratorin interfaceIterable<K>- Specified by:
iteratorin interfaceSet<K>- Specified by:
iteratorin classAbstractCollection<T extends SecurityEntity<K>>
-
size
public int size()- Specified by:
sizein interfaceCollection<K>- Specified by:
sizein interfaceSet<K>- Specified by:
sizein classAbstractCollection<T extends SecurityEntity<K>>
-
toString
- Overrides:
toStringin classAbstractCollection<T extends SecurityEntity<K>>
-
add
entity 를 추가한다. id 가 없거나 id 또는 name 이 이미 존재하면 추가하지 않는다.- Specified by:
addin interfaceCollection<K>- Specified by:
addin interfaceSet<K>- Overrides:
addin classAbstractCollection<T extends SecurityEntity<K>>- Parameters:
o- 추가할 entity- Returns:
- 추가되었으면
true
-
contains
id 가 같은 entity 가 있는지 확인한다.- Specified by:
containsin interfaceCollection<K>- Specified by:
containsin interfaceSet<K>- Overrides:
containsin classAbstractCollection<T extends SecurityEntity<K>>- Parameters:
o- 확인할 object- Returns:
- 같은 id 의 entity 가 있으면
true
-
remove
id 가 같은 entity 를 제거한다.- Specified by:
removein interfaceCollection<K>- Specified by:
removein interfaceSet<K>- Overrides:
removein classAbstractCollection<T extends SecurityEntity<K>>- Parameters:
o- 제거할 object- Returns:
- 제거되었으면
true
-
getByName
이름(대소문자 구분 없음)에 해당하는 entity 를 구한다.- Parameters:
name- 찾을 이름- Returns:
- 이름에 해당하는 entity, 없으면 빈 Optional
-
getById
id 에 해당하는 entity 를 구한다.- Parameters:
id- 찾을 id- Returns:
- id 에 해당하는 entity, 없으면 빈 Optional
-
contains
전달된 모든 요소가 Set에 포함되어 있는지 확인합니다. (AND Stratage)- Parameters:
tArray- 확인하려는 요소 목록 (가변인자 또는 배열)- Returns:
- 모든 요소가 존재하면 true, 배열이 비어있으면 false, 전달된 요소 중 하나라도 없으면 false (AND Stratage)
-
containsAll
전달된 모든 요소가 Set 에 포함되어 있는지 확인합니다. (AND Stratage)- Parameters:
tArray- 확인하려는 요소 목록 (가변인자 또는 배열)- Returns:
- 모든 요소가 존재하면 true, 배열이 비어있으면 false, 전달된 요소 중 하나라도 없으면 false
-