Package top.focess.qq.api.util.session
Class Session
- java.lang.Object
-
- top.focess.qq.api.util.session.Session
-
- All Implemented Interfaces:
Serializable,SectionMap
- Direct Known Subclasses:
SessionSection
public class Session extends Object implements SectionMap
This class is used to build better communication between Command and CommandSender. It can save something in the executing process and can be used for future.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcompute(String key, java.util.function.BiFunction<? super String,? super Object,?> remappingFunction)compute the value of the key-value pairbooleancontains(String key)Indicate there is a key-value pair named keybooleancontainsSection(String key)Indicate there is a section named keySessionSectioncreateSection(String key)Create the section named key Note: if the section named key already exists, it will be replaced by a new section<T> Tget(String key)Get the value of the key-value pair<T> TgetOrDefault(String key, T defaultValue)Get the value of the key-value pairSectionMapgetSection(String key)Get the section named key Note: if the section named key does not exist, it will be createdMap<String,Object>getValues()Get all the key-value pairsvoidremove(String key)Remove the key-value pair named keyvoidset(String key, Object value)Store the key-value pairStringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface top.focess.qq.api.util.SectionMap
keys
-
-
-
-
Method Detail
-
createSection
public SessionSection createSection(String key)
Description copied from interface:SectionMapCreate the section named key Note: if the section named key already exists, it will be replaced by a new section- Specified by:
createSectionin interfaceSectionMap- Parameters:
key- the key of the Section- Returns:
- a section named key
-
getValues
public Map<String,Object> getValues()
Description copied from interface:SectionMapGet all the key-value pairs- Specified by:
getValuesin interfaceSectionMap- Returns:
- all the key-value pairs
-
getSection
public SectionMap getSection(String key)
Description copied from interface:SectionMapGet the section named key Note: if the section named key does not exist, it will be created- Specified by:
getSectionin interfaceSectionMap- Parameters:
key- the key of the Section- Returns:
- the section named key
-
containsSection
public boolean containsSection(String key)
Description copied from interface:SectionMapIndicate there is a section named key- Specified by:
containsSectionin interfaceSectionMap- Parameters:
key- the key of the Section- Returns:
- true there is a section named key, false otherwise
-
set
public void set(String key, Object value)
Description copied from interface:SectionMapStore the key-value pair- Specified by:
setin interfaceSectionMap- Parameters:
key- the key of the key-value pairvalue- the value of the key-value pair
-
get
public <T> T get(String key)
Description copied from interface:SectionMapGet the value of the key-value pair- Specified by:
getin interfaceSectionMap- Type Parameters:
T- the value type- Parameters:
key- the key of the key-value pair- Returns:
- the value
-
getOrDefault
public <T> T getOrDefault(String key, T defaultValue)
Description copied from interface:SectionMapGet the value of the key-value pair- Specified by:
getOrDefaultin interfaceSectionMap- Type Parameters:
T- the value type- Parameters:
key- the key of the key-value pairdefaultValue- the default value- Returns:
- the value or defaultValue if there is no value
-
contains
public boolean contains(String key)
Description copied from interface:SectionMapIndicate there is a key-value pair named key- Specified by:
containsin interfaceSectionMap- Parameters:
key- the key of the key-value pair- Returns:
- true there is a key-value pair named key, false otherwise
-
remove
public void remove(String key)
Description copied from interface:SectionMapRemove the key-value pair named key- Specified by:
removein interfaceSectionMap- Parameters:
key- the key of the key-value pair
-
compute
public void compute(String key, java.util.function.BiFunction<? super String,? super Object,?> remappingFunction)
Description copied from interface:SectionMapcompute the value of the key-value pair- Specified by:
computein interfaceSectionMap- Parameters:
key- the key of the key-value pairremappingFunction- the remapping function
-
-