new module: utils
This commit is contained in:
1
utils/build.gradle
Normal file
1
utils/build.gradle
Normal file
@@ -0,0 +1 @@
|
||||
apply from: rootDir.toPath().resolve('logic.gradle').toFile()
|
||||
2
utils/gradle.properties
Normal file
2
utils/gradle.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
# suppress inspection "UnusedProperty" for whole file
|
||||
module.name=utils
|
||||
23
utils/src/main/java/mc/utils/Table.java
Normal file
23
utils/src/main/java/mc/utils/Table.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package mc.utils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Table<C, R, V> {
|
||||
|
||||
private final Map<C, Map<R, V>> map = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
public V getColumnAndRow(C column, R row) {
|
||||
if (!map.containsKey(column)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return map.get(column).get(row);
|
||||
}
|
||||
|
||||
public void put(C column, R row, V value) {
|
||||
map.computeIfAbsent(column, c -> new HashMap<>()).put(row, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user