From ef8cdb87cf47b5586f6214e58f658ad9db04677e Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sat, 29 Jun 2024 22:15:56 +0200 Subject: [PATCH] Add ImmutableMap --- .../sosengine/base/types/ImmutableMap.java | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 base/src/main/java/de/staropensource/sosengine/base/types/ImmutableMap.java diff --git a/base/src/main/java/de/staropensource/sosengine/base/types/ImmutableMap.java b/base/src/main/java/de/staropensource/sosengine/base/types/ImmutableMap.java new file mode 100644 index 0000000..56c3d87 --- /dev/null +++ b/base/src/main/java/de/staropensource/sosengine/base/types/ImmutableMap.java @@ -0,0 +1,163 @@ +/* + * STAROPENSOURCE ENGINE SOURCE FILE + * Copyright (c) 2024 The StarOpenSource Engine Contributors + * Licensed under the GNU Affero General Public License v3 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.staropensource.sosengine.base.types; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiFunction; + +/** + * An unmodifiable {@link Map}. + * {@inheritDoc} + * + * @since 1-alpha1 + */ +@SuppressWarnings({ "unused" }) +public class ImmutableMap extends HashMap { + /** + * Constructor. + * + * @since 1-alpha1 + */ + public ImmutableMap() {} + + /** + * Converts some {@link Map} into a {@link ImmutableMap}. + * + * @param map {@link Map} to convert + * @since 1-alpha1 + */ + public ImmutableMap(@NotNull Map map) { + for (K key : map.keySet()) + put(key, map.get(key)); + } + + /** + * Note: This method is a stub.
+ * {@inheritDoc} + * + * @since 1-alpha1 + */ + @Nullable + @Override + public V put(K key, V value) { + return null; + } + + /** + * Note: This method is a stub.
+ * {@inheritDoc} + * + * @since 1-alpha1 + */ + @Nullable + @Override + public V remove(Object key) { + return null; + } + + /** + * Note: This method is a stub.
+ * {@inheritDoc} + * + * @since 1-alpha1 + */ + @Override + public void putAll(@NotNull Map m) {} + + /** + * Note: This method is a stub.
+ * {@inheritDoc} + * + * @since 1-alpha1 + */ + @Override + public void clear() {} + + /** + * Note: This method is a stub.
+ * {@inheritDoc} + * + * @since 1-alpha1 + */ + @Override + public void replaceAll(BiFunction function) {} + + /** + * Note: This method is a stub.
+ * {@inheritDoc} + * + * @since 1-alpha1 + */ + @Nullable + @Override + public V putIfAbsent(K key, V value) { + return null; + } + + /** + * Note: This method is a stub.
+ * {@inheritDoc} + * + * @since 1-alpha1 + */ + @Override + public boolean remove(Object key, Object value) { + return false; + } + + /** + * Note: This method is a stub.
+ * {@inheritDoc} + * + * @since 1-alpha1 + */ + @Override + public boolean replace(K key, V oldValue, V newValue) { + return false; + } + + /** + * Note: This method is a stub.
+ * {@inheritDoc} + * + * @since 1-alpha1 + */ + @Nullable + @Override + public V replace(K key, V value) { + return null; + } + + /** + * Note: This method is a stub.
+ * {@inheritDoc} + * + * @since 1-alpha1 + */ + @Nullable + @Override + public V merge(K key, @NotNull V value, @NotNull BiFunction remappingFunction) { + return null; + } +}