From dff173222d114088a4825fb715eaf85734d3221d Mon Sep 17 00:00:00 2001 From: Speiger Date: Wed, 6 Oct 2021 17:48:37 +0200 Subject: [PATCH] Collections are now copyable --- .../templates/collections/AbstractCollection.template | 3 +++ .../collections/templates/collections/Collection.template | 2 +- .../collections/templates/utils/Collections.template | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template b/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template index e52c6a8..6f2de72 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template @@ -35,6 +35,9 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle return modified; } + @Override + public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } + #if !TYPE_OBJECT /** {@inheritDoc} *

This default implementation delegates to the corresponding type-specific function. diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template b/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template index 5af174f..883a94b 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template @@ -129,7 +129,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection, ITE * It can be compared to Cloneable but with less exception risk * @return a Shallow Copy of the collection */ - public default COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } + public COLLECTION KEY_GENERIC_TYPE copy(); #if !TYPE_OBJECT /** diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template b/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template index 0749298..e8ac51f 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template @@ -128,6 +128,9 @@ public class COLLECTIONS return c.iterator(); } + @Override + public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } + @Override @Primitive public boolean remove(Object o) { synchronized(mutex) { return c.remove(o); } } @@ -222,6 +225,8 @@ public class COLLECTIONS @Override public ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.unmodifiable(c.iterator()); } @Override + public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); } + @Override @Deprecated public boolean remove(Object o) { throw new UnsupportedOperationException(); } @Override @@ -358,5 +363,7 @@ public class COLLECTIONS public void clear() {} @Override public int size() { return 0; } + @Override + public EmptyCollection KEY_GENERIC_TYPE copy() { return this; } } } \ No newline at end of file