Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.dusk.cache.updated;
- import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
- public enum Protocol {
- BUILD_877(),
- BUILD_OSRS_180();
- static {
- for (DefinitionType definitionType : DefinitionType.values()) {
- for (Protocol protocol : Protocol.values()) {
- if (definitionType.contains(protocol) && !protocol.contains(definitionType)) {
- throw new IllegalArgumentException(protocol + " does not support " + definitionType + ".");
- }
- }
- }
- }
- static class DefinitionLookup {
- private final DefinitionType type;
- private final int fs, folder, file;
- private DefinitionLookup(DefinitionType type, int fs, int folder, int file) {
- this.type = type;
- this.fs = fs;
- this.folder = folder;
- this.file = file;
- }
- public DefinitionLookup(DefinitionType type, int fs, int folder) {
- this(type, fs, folder, -1);
- }
- public DefinitionLookup(DefinitionType type, int fs) {
- this(type, fs, -1, -1);
- }
- public int getFs() {
- return fs;
- }
- public int getFolder() {
- return folder;
- }
- public int getFile() {
- return file;
- }
- }
- private final Object2ObjectOpenHashMap<DefinitionType, DefinitionLookup> map;
- Protocol(DefinitionLookup... lookups) {
- this.map = new Object2ObjectOpenHashMap<>();
- for (DefinitionLookup lookup : lookups) {
- map.put(lookup.type, lookup);
- }
- }
- public boolean contains(DefinitionType type) {
- return map.containsKey(type);
- }
- public DefinitionLookup lookup(DefinitionType type) {
- return map.get(type);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement