forked from StarOpenSource/Engine
Add more Immutable* types
This commit is contained in:
parent
ab46a25911
commit
3f7edd0968
11 changed files with 649 additions and 39 deletions
|
@ -33,8 +33,8 @@ import de.staropensource.sosengine.base.logging.CrashHandler;
|
||||||
import de.staropensource.sosengine.base.logging.Logger;
|
import de.staropensource.sosengine.base.logging.Logger;
|
||||||
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||||
import de.staropensource.sosengine.base.types.CodePart;
|
import de.staropensource.sosengine.base.types.CodePart;
|
||||||
import de.staropensource.sosengine.base.types.ImmutableMap;
|
|
||||||
import de.staropensource.sosengine.base.types.dependency.DependencyVector;
|
import de.staropensource.sosengine.base.types.dependency.DependencyVector;
|
||||||
|
import de.staropensource.sosengine.base.types.immutable.ImmutableHashMap;
|
||||||
import de.staropensource.sosengine.base.utility.DependencyResolver;
|
import de.staropensource.sosengine.base.utility.DependencyResolver;
|
||||||
import de.staropensource.sosengine.base.utility.Miscellaneous;
|
import de.staropensource.sosengine.base.utility.Miscellaneous;
|
||||||
import de.staropensource.sosengine.base.utility.PlaceholderEngine;
|
import de.staropensource.sosengine.base.utility.PlaceholderEngine;
|
||||||
|
@ -94,7 +94,7 @@ public final class Engine implements SubsystemMainClass {
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@Getter
|
@Getter
|
||||||
private ImmutableMap<@NotNull SubsystemMainClass, @NotNull DependencyVector> subsystems = new ImmutableMap<>();
|
private ImmutableHashMap<@NotNull SubsystemMainClass, @NotNull DependencyVector> subsystems = new ImmutableHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the engine is shutting down.
|
* Indicates if the engine is shutting down.
|
||||||
|
@ -282,7 +282,7 @@ public final class Engine implements SubsystemMainClass {
|
||||||
if (subsystemsMap.get(subsystem) == null)
|
if (subsystemsMap.get(subsystem) == null)
|
||||||
subsystemsMap.remove(subsystem);
|
subsystemsMap.remove(subsystem);
|
||||||
|
|
||||||
subsystems = new ImmutableMap<>(subsystemsMap);
|
subsystems = new ImmutableHashMap<>(subsystemsMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,211 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.types.immutable;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An unmodifiable {@link ArrayList}.
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class ImmutableArrayList<E> extends ArrayList<E> {
|
||||||
|
/**
|
||||||
|
* Creates a new immutable array list.
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
|
public ImmutableArrayList() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a {@link LinkedList} into a {@link ImmutableArrayList}.
|
||||||
|
*
|
||||||
|
* @param list {@link List} to convert
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
|
public ImmutableArrayList(@NotNull List<E> list) {
|
||||||
|
super.addAll(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean add(E e) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean remove(Object o) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean addAll(@NotNull Collection<? extends E> c) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean addAll(int index, @NotNull Collection<? extends E> c) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean removeAll(@NotNull Collection<?> c) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean retainAll(@NotNull Collection<?> c) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void replaceAll(UnaryOperator<E> operator) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sort(Comparator<? super E> c) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public E set(int index, E element) throws UnsupportedOperationException {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void add(int index, E element) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public E remove(int index) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addFirst(E e) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addLast(E e) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public E removeFirst() {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, array list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public E removeLast() {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableArrayList");
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.staropensource.sosengine.base.types;
|
package de.staropensource.sosengine.base.types.immutable;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -33,131 +33,128 @@ import java.util.function.BiFunction;
|
||||||
* @since 1-alpha1
|
* @since 1-alpha1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unused" })
|
@SuppressWarnings({ "unused" })
|
||||||
public class ImmutableMap<K, V> extends HashMap<K, V> {
|
public class ImmutableHashMap<K, V> extends HashMap<K, V> {
|
||||||
/**
|
/**
|
||||||
* Creates a new immutable map.
|
* Creates a new immutable hash map.
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @since 1-alpha1
|
||||||
*/
|
*/
|
||||||
public ImmutableMap() {}
|
public ImmutableHashMap() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a {@link Map} into a {@link ImmutableMap}.
|
* Converts a {@link Map} into a {@link ImmutableHashMap}.
|
||||||
*
|
*
|
||||||
* @param map {@link Map} to convert
|
* @param map {@link Map} to convert
|
||||||
* @since 1-alpha1
|
* @since 1-alpha1
|
||||||
*/
|
*/
|
||||||
public ImmutableMap(@NotNull Map<K, V> map) {
|
public ImmutableHashMap(@NotNull Map<K, V> map) {
|
||||||
for (K key : map.keySet())
|
for (K key : map.keySet())
|
||||||
super.put(key, map.get(key));
|
super.put(key, map.get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This method is a stub.<br/>
|
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @throws UnsupportedOperationException always, hash map is immutable
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public V put(K key, V value) {
|
public V put(K key, V value) {
|
||||||
return null;
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableHashMap");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This method is a stub.<br/>
|
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @throws UnsupportedOperationException always, hash map is immutable
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public V remove(Object key) {
|
public V remove(Object key) {
|
||||||
return null;
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableHashMap");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This method is a stub.<br/>
|
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @throws UnsupportedOperationException always, hash map is immutable
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void putAll(@NotNull Map<? extends K, ? extends V> m) {}
|
public void putAll(@NotNull Map<? extends K, ? extends V> m) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This method is a stub.<br/>
|
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @throws UnsupportedOperationException always, hash map is immutable
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void clear() {}
|
public void clear() {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This method is a stub.<br/>
|
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @throws UnsupportedOperationException always, hash map is immutable
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {}
|
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This method is a stub.<br/>
|
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @throws UnsupportedOperationException always, hash map is immutable
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public V putIfAbsent(K key, V value) {
|
public V putIfAbsent(K key, V value) {
|
||||||
return null;
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableHashMap");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This method is a stub.<br/>
|
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @throws UnsupportedOperationException always, hash map is immutable
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object key, Object value) {
|
public boolean remove(Object key, Object value) {
|
||||||
return false;
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableHashMap");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This method is a stub.<br/>
|
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @throws UnsupportedOperationException always, hash map is immutable
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean replace(K key, V oldValue, V newValue) {
|
public boolean replace(K key, V oldValue, V newValue) {
|
||||||
return false;
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableHashMap");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This method is a stub.<br/>
|
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @throws UnsupportedOperationException always, hash map is immutable
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public V replace(K key, V value) {
|
public V replace(K key, V value) {
|
||||||
return null;
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableHashMap");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This method is a stub.<br/>
|
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @since 1-alpha1
|
* @throws UnsupportedOperationException always, hash map is immutable
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public V merge(K key, @NotNull V value, @NotNull BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
|
public V merge(K key, @NotNull V value, @NotNull BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
|
||||||
return null;
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableHashMap");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,160 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.types.immutable;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An unmodifiable {@link Map}.
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class ImmutableLinkedHashMap<K, V> extends LinkedHashMap<K, V> {
|
||||||
|
/**
|
||||||
|
* Creates a new immutable linked hash map.
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
|
public ImmutableLinkedHashMap() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a {@link Map} into a {@link ImmutableLinkedHashMap}.
|
||||||
|
*
|
||||||
|
* @param map {@link Map} to convert
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
|
public ImmutableLinkedHashMap(@NotNull Map<K, V> map) {
|
||||||
|
for (K key : map.keySet())
|
||||||
|
super.put(key, map.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked hash map is immutable
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public V put(K key, V value) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked hash map is immutable
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public V remove(Object key) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked hash map is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void putAll(@NotNull Map<? extends K, ? extends V> m) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked hash map is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked hash map is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked hash map is immutable
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public V putIfAbsent(K key, V value) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked hash map is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean remove(Object key, Object value) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked hash map is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean replace(K key, V oldValue, V newValue) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked hash map is immutable
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public V replace(K key, V value) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedHashMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked hash map is immutable
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public V merge(K key, @NotNull V value, @NotNull BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedHashMap");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,214 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.staropensource.sosengine.base.types.immutable;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An unmodifiable {@link LinkedList}.
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "unused" })
|
||||||
|
public class ImmutableLinkedList<E> extends LinkedList<E> {
|
||||||
|
/**
|
||||||
|
* Creates a new immutable linked list.
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
|
public ImmutableLinkedList() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a {@link LinkedList} into a {@link ImmutableLinkedList}.
|
||||||
|
*
|
||||||
|
* @param list {@link List} to convert
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
|
public ImmutableLinkedList(@NotNull List<E> list) {
|
||||||
|
super.addAll(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean add(E e) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean remove(Object o) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean addAll(@NotNull Collection<? extends E> c) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean addAll(int index, @NotNull Collection<? extends E> c) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean removeAll(@NotNull Collection<?> c) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean retainAll(@NotNull Collection<?> c) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void replaceAll(UnaryOperator<E> operator) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sort(Comparator<? super E> c) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public E set(int index, E element) throws UnsupportedOperationException {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void add(int index, E element) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public E remove(int index) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addFirst(E e) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addLast(E e) {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public E removeFirst() {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always, linked list is immutable
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public E removeLast() {
|
||||||
|
throw new UnsupportedOperationException("This method cannot be executed on an ImmutableLinkedList");
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ module sosengine.base {
|
||||||
exports de.staropensource.sosengine.base.logging.implementation;
|
exports de.staropensource.sosengine.base.logging.implementation;
|
||||||
exports de.staropensource.sosengine.base.types;
|
exports de.staropensource.sosengine.base.types;
|
||||||
exports de.staropensource.sosengine.base.types.dependency;
|
exports de.staropensource.sosengine.base.types.dependency;
|
||||||
|
exports de.staropensource.sosengine.base.types.immutable;
|
||||||
exports de.staropensource.sosengine.base.types.vectors;
|
exports de.staropensource.sosengine.base.types.vectors;
|
||||||
exports de.staropensource.sosengine.base.types.versioning;
|
exports de.staropensource.sosengine.base.types.versioning;
|
||||||
exports de.staropensource.sosengine.base.utility;
|
exports de.staropensource.sosengine.base.utility;
|
||||||
|
@ -51,6 +52,7 @@ module sosengine.base {
|
||||||
opens de.staropensource.sosengine.base.logging.implementation;
|
opens de.staropensource.sosengine.base.logging.implementation;
|
||||||
opens de.staropensource.sosengine.base.types;
|
opens de.staropensource.sosengine.base.types;
|
||||||
opens de.staropensource.sosengine.base.types.dependency;
|
opens de.staropensource.sosengine.base.types.dependency;
|
||||||
|
opens de.staropensource.sosengine.base.types.immutable;
|
||||||
opens de.staropensource.sosengine.base.types.vectors;
|
opens de.staropensource.sosengine.base.types.vectors;
|
||||||
opens de.staropensource.sosengine.base.types.versioning;
|
opens de.staropensource.sosengine.base.types.versioning;
|
||||||
opens de.staropensource.sosengine.base.utility;
|
opens de.staropensource.sosengine.base.utility;
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/**
|
||||||
|
* Defines the OpenGL Graphics API and {@code opengl} subsystem, which allows for communicating with the graphics card via OpenGL.
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
module sosengine.opengl {
|
module sosengine.opengl {
|
||||||
// Dependencies
|
// Dependencies
|
||||||
// -> Subsystems
|
// -> Subsystems
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/**
|
||||||
|
* Defines the {@code graphics} subsystem, which allows creating windows and drawing pixels onto the screen.
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
module sosengine.graphics {
|
module sosengine.graphics {
|
||||||
// Dependencies
|
// Dependencies
|
||||||
// -> Subsystems
|
// -> Subsystems
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/**
|
||||||
|
* Defines the Vulkan Graphics API and {@code vulkan} subsystem, which allows for communicating with the graphics card via Vulkan.
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
module sosengine.vulkan {
|
module sosengine.vulkan {
|
||||||
// Dependencies
|
// Dependencies
|
||||||
// -> Subsystems
|
// -> Subsystems
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/**
|
||||||
|
* Defines the {@code slf4j-compat} subsystem, which helps bridging the gap between SLF4J and the sos!engine by forwarding all SLF4J calls to the engine you love.
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
module sosengine.slf4j_compat {
|
module sosengine.slf4j_compat {
|
||||||
// Dependencies
|
// Dependencies
|
||||||
// -> Subsystems
|
// -> Subsystems
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
/**
|
||||||
|
* Defines the sos!engine test application, used by engine developers to test their changes.
|
||||||
|
* This module is very uninteresting for non-engine developers.
|
||||||
|
*
|
||||||
|
* @since 1-alpha1
|
||||||
|
*/
|
||||||
open module sosengine.testapp {
|
open module sosengine.testapp {
|
||||||
// Dependencies
|
// Dependencies
|
||||||
// -> Subsystems
|
// -> Subsystems
|
||||||
|
|
Loading…
Reference in a new issue