mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-02-27 21:31:33 +01:00
🧑💼 manager classes
Took 1 minute
This commit is contained in:
parent
9c87f768ea
commit
50580f3e3d
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Auction House
|
||||
* Copyright 2023 Kiran Hart
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package ca.tweetzy.auctionhouse.api.manager;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public abstract class KeyValueManager<K, V> extends Manager {
|
||||
|
||||
protected final Map<K, V> managerContent = new ConcurrentHashMap<>();
|
||||
|
||||
public KeyValueManager(@NonNull String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public V get(@NonNull final K k) {
|
||||
return this.managerContent.getOrDefault(k, null);
|
||||
}
|
||||
|
||||
public void add(@NonNull final K k, @NonNull final V v) {
|
||||
if (this.managerContent.containsKey(k)) return;
|
||||
this.managerContent.put(k, v);
|
||||
}
|
||||
|
||||
public void remove(@NonNull final K k) {
|
||||
this.managerContent.remove(k);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.managerContent.clear();
|
||||
}
|
||||
|
||||
public Map<K, V> getManagerContent() {
|
||||
return this.managerContent;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Auction House
|
||||
* Copyright 2023 Kiran Hart
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package ca.tweetzy.auctionhouse.api.manager;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
public abstract class Manager {
|
||||
|
||||
protected String name;
|
||||
|
||||
public Manager(@NonNull final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public abstract void load();
|
||||
}
|
Loading…
Reference in New Issue
Block a user