Package com.ptsmods.mysqlw.collection
Class DbSet<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
com.ptsmods.mysqlw.collection.DbSet<E>
- All Implemented Interfaces:
DbCollection
,Iterable<E>
,Collection<E>
,Set<E>
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> c) addAllAsync
(@NotNull Collection<? extends E> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) containsAllAsync
(@NotNull Collection<?> c) @NotNull CompletableFuture<Boolean>
getDb()
@NotNull BiFunction<String,
DbCollection, E> @NotNull BiFunction<E,
DbCollection, String> getName()
static <E> DbSet<E>
Gets a set from cache or creates a new one.static <E> DbSet<E>
getSet
(@NotNull Database db, @NotNull String name, @NotNull BiFunction<E, DbCollection, String> elementToString, @NotNull BiFunction<String, DbCollection, E> elementFromString) Gets a set from cache or creates a new one.getTable()
boolean
isEmpty()
@NotNull CompletableFuture<Boolean>
iterator()
@NotNull CompletableFuture<Iterator<E>>
static <E> DbSet<E>
parseString
(@NotNull Database db, @NotNull String s, @NotNull BiFunction<E, DbCollection, String> elementToString, @NotNull BiFunction<String, DbCollection, E> elementFromString) Parses a String representation of a DbSet into a DbSet.boolean
boolean
removeAll
(Collection<?> c) removeAllAsync
(@NotNull Collection<?> c) boolean
retainAll
(Collection<?> c) retainAllAsync
(@NotNull Collection<?> c) <T> CompletableFuture<T>
void
setExecutor
(Executor executor) int
size()
@NotNull CompletableFuture<Integer>
@NotNull Object[]
toArray()
<T> @NotNull T[]
toArray
(@NotNull T[] a) <T> @NotNull CompletableFuture<T[]>
toArrayAsync
(@NotNull T[] a) @NotNull CompletableFuture<Set<E>>
toString()
Methods inherited from class java.util.AbstractSet
equals, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
spliterator
-
Method Details
-
parseString
public static <E> DbSet<E> parseString(@NotNull @NotNull Database db, @NotNull @NotNull String s, @NotNull @NotNull BiFunction<E, DbCollection, String> elementToString, @NotNull @NotNull BiFunction<String, DbCollection, E> elementFromString) Parses a String representation of a DbSet into a DbSet.- Type Parameters:
E
- The type of the elements in this set.- Parameters:
db
- The database this set belongs to. Used when creating a new set.s
- The String to parse.elementToString
- The function used to convert an element of this set into a String. Used when creating a new set.elementFromString
- The function used to convert an element of this set into a String. Used when creating a new set.- Returns:
- A new DbSet or a cached one if available.
-
getSet
public static <E> DbSet<E> getSet(@NotNull @NotNull Database db, @NotNull @NotNull String name, @NotNull @NotNull Class<E> type) Gets a set from cache or creates a new one.- Type Parameters:
E
- The type of the elements in this set.- Parameters:
db
- The database this set belongs to. Used when creating a new map.name
- The name of this set.type
- The Class of type E if you've registered a type converter onDbCF
. Used when creating a new set.- Returns:
- A new DbSet or a cached one if available.
-
getSet
public static <E> DbSet<E> getSet(@NotNull @NotNull Database db, @NotNull @NotNull String name, @NotNull @NotNull BiFunction<E, DbCollection, String> elementToString, @NotNull @NotNull BiFunction<String, DbCollection, E> elementFromString) Gets a set from cache or creates a new one.- Type Parameters:
E
- The type of the elements in this set.- Parameters:
db
- The database this map belongs to. Used when creating a new map.name
- The name of this set.elementToString
- The function used to convert an element of this set into a String. Used when creating a new set.elementFromString
- The function used to convert an element of this set into a String. Used when creating a new set.- Returns:
- A new DbSet or a cached one if available.
-
setExecutor
-
getExecutor
-
runAsync
-
runAsync
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-
sizeAsync
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceSet<E>
- Overrides:
isEmpty
in classAbstractCollection<E>
-
isEmptyAsync
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Overrides:
contains
in classAbstractCollection<E>
-
containsAsync
-
iterator
-
iteratorAsync
-
toArray
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
toArrayAsync
-
toArray
@NotNull public <T> @NotNull T[] toArray(@NotNull @NotNull T[] a) - Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
toArrayAsync
-
add
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classAbstractCollection<E>
-
addAsync
-
remove
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classAbstractCollection<E>
-
removeAsync
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
- Overrides:
containsAll
in classAbstractCollection<E>
-
containsAllAsync
-
addAll
- Specified by:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceSet<E>
- Overrides:
addAll
in classAbstractCollection<E>
-
addAllAsync
-
retainAll
- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceSet<E>
- Overrides:
retainAll
in classAbstractCollection<E>
-
retainAllAsync
-
removeAll
- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceSet<E>
- Overrides:
removeAll
in classAbstractSet<E>
-
removeAllAsync
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Overrides:
clear
in classAbstractCollection<E>
-
clearAsync
-
getDb
- Specified by:
getDb
in interfaceDbCollection
- Returns:
- The database this collection works with.
-
getTable
- Specified by:
getTable
in interfaceDbCollection
- Returns:
- The table this collection works with.
-
getName
- Specified by:
getName
in interfaceDbCollection
- Returns:
- The name of this collection. Used to cache and parse from Strings.
-
toString
- Overrides:
toString
in classAbstractCollection<E>
-
toHashSet
-
toHashSetAsync
-
getElementToString
-
getElementFromString
-