Move delegate collection to commons
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Johannes Frohnmeyer 2022-12-12 18:01:58 +01:00
parent 3f86f09606
commit 486503d638
Signed by: Johannes
GPG Key ID: E76429612C2929F4
6 changed files with 7 additions and 281 deletions

View File

@ -1,5 +1,6 @@
plugins { plugins {
java java
id("jf.manifold")
} }
repositories { repositories {
@ -11,13 +12,4 @@ dependencies {
annotationProcessor(project(":gson-compile-processor")) annotationProcessor(project(":gson-compile-processor"))
compileOnly(project(":gson-compile-annotations")) compileOnly(project(":gson-compile-annotations"))
implementation(project(":gson-compile-core")) implementation(project(":gson-compile-core"))
val manifoldVersion = "2022.1.27"
implementation("systems.manifold:manifold-ext-rt:$manifoldVersion")
annotationProcessor("systems.manifold:manifold-ext:$manifoldVersion")
}
tasks.withType<JavaCompile> {
options.compilerArgs.addAll(arrayOf("-AgsonCompileNoReflect", "-Xplugin:Manifold no-bootstrap"))
} }

View File

@ -1,14 +1,14 @@
package io.gitlab.jfronny.gson.compile.processor.adapter.impl; package io.gitlab.jfronny.gson.compile.processor.adapter.impl;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import io.gitlab.jfronny.commons.data.MutCollection;
import io.gitlab.jfronny.gson.compile.processor.Cl; import io.gitlab.jfronny.gson.compile.processor.Cl;
import io.gitlab.jfronny.gson.compile.processor.TypeHelper; import io.gitlab.jfronny.gson.compile.processor.TypeHelper;
import io.gitlab.jfronny.gson.compile.processor.adapter.Adapter; import io.gitlab.jfronny.gson.compile.processor.adapter.Adapter;
import io.gitlab.jfronny.gson.compile.processor.util.ValUtils;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
import javax.lang.model.type.*; import javax.lang.model.type.DeclaredType;
import javax.tools.Diagnostic; import javax.lang.model.type.TypeMirror;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
@ -19,7 +19,7 @@ public class CollectionAdapter extends Adapter<CollectionAdapter.Hydrated> {
} }
public class Hydrated extends Adapter<CollectionAdapter.Hydrated>.Hydrated { public class Hydrated extends Adapter<CollectionAdapter.Hydrated>.Hydrated {
private static final Map<Class<?>, List<Class<?>>> SUPPORTED = ValUtils.mapOf( private static final Map<Class<?>, List<Class<?>>> SUPPORTED = MutCollection.mapOf(
Set.class, List.of(LinkedHashSet.class, HashSet.class, TreeSet.class), Set.class, List.of(LinkedHashSet.class, HashSet.class, TreeSet.class),
List.class, List.of(ArrayList.class, LinkedList.class), List.class, List.of(ArrayList.class, LinkedList.class),
Queue.class, List.of(ArrayDeque.class, LinkedList.class), Queue.class, List.of(ArrayDeque.class, LinkedList.class),

View File

@ -4,7 +4,6 @@ import com.squareup.javapoet.*;
import io.gitlab.jfronny.gson.compile.processor.Cl; import io.gitlab.jfronny.gson.compile.processor.Cl;
import io.gitlab.jfronny.gson.compile.processor.TypeHelper; import io.gitlab.jfronny.gson.compile.processor.TypeHelper;
import io.gitlab.jfronny.gson.compile.processor.adapter.Adapter; import io.gitlab.jfronny.gson.compile.processor.adapter.Adapter;
import io.gitlab.jfronny.gson.compile.processor.util.ValUtils;
import javax.lang.model.element.ElementKind; import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;

View File

@ -1,196 +0,0 @@
package io.gitlab.jfronny.gson.compile.processor.util;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.function.*;
import java.util.stream.Stream;
public class DelegateList<T> implements List<T> {
private final List<T> delegate;
public DelegateList(List<T> delegate) {
Objects.requireNonNull(delegate);
this.delegate = delegate instanceof DelegateList<T> dl ? dl.unwrap() : delegate;
}
@Override
public int size() {
return delegate.size();
}
@Override
public boolean isEmpty() {
return delegate.isEmpty();
}
@Override
public boolean contains(Object o) {
return delegate.contains(o);
}
@NotNull
@Override
public Iterator<T> iterator() {
return delegate.iterator();
}
@Override
public void forEach(Consumer<? super T> action) {
delegate.forEach(action);
}
@NotNull
@Override
public Object[] toArray() {
return delegate.toArray();
}
@NotNull
@Override
public <T1> T1[] toArray(@NotNull T1[] t1s) {
return delegate.toArray(t1s);
}
@Override
public <T1> T1[] toArray(IntFunction<T1[]> generator) {
return delegate.toArray(generator);
}
@Override
public boolean add(T t) {
return delegate.add(t);
}
@Override
public boolean remove(Object o) {
return delegate.remove(o);
}
@Override
public boolean containsAll(@NotNull Collection<?> collection) {
return delegate.containsAll(collection);
}
@Override
public boolean addAll(@NotNull Collection<? extends T> collection) {
return delegate.addAll(collection);
}
@Override
public boolean addAll(int i, @NotNull Collection<? extends T> collection) {
return delegate.addAll(i, collection);
}
@Override
public boolean removeAll(@NotNull Collection<?> collection) {
return delegate.removeAll(collection);
}
@Override
public boolean removeIf(Predicate<? super T> filter) {
return delegate.removeIf(filter);
}
@Override
public boolean retainAll(@NotNull Collection<?> collection) {
return delegate.retainAll(collection);
}
@Override
public void replaceAll(UnaryOperator<T> operator) {
delegate.replaceAll(operator);
}
@Override
public void sort(Comparator<? super T> c) {
delegate.sort(c);
}
@Override
public void clear() {
delegate.clear();
}
@Override
public T get(int i) {
return delegate.get(i);
}
@Override
public T set(int i, T t) {
return delegate.set(i, t);
}
@Override
public void add(int i, T t) {
delegate.add(i, t);
}
@Override
public T remove(int i) {
return delegate.remove(i);
}
@Override
public int indexOf(Object o) {
return delegate.indexOf(o);
}
@Override
public int lastIndexOf(Object o) {
return delegate.lastIndexOf(o);
}
@NotNull
@Override
public ListIterator<T> listIterator() {
return delegate.listIterator();
}
@NotNull
@Override
public ListIterator<T> listIterator(int i) {
return delegate.listIterator(i);
}
@NotNull
@Override
public List<T> subList(int i, int i1) {
return delegate.subList(i, i1);
}
@Override
public Spliterator<T> spliterator() {
return delegate.spliterator();
}
@Override
public Stream<T> stream() {
return delegate.stream();
}
@Override
public Stream<T> parallelStream() {
return delegate.parallelStream();
}
@Override
public int hashCode() {
return delegate.hashCode();
}
@Override
public boolean equals(Object obj) {
return obj instanceof DelegateList<?> dl ? delegate.equals(dl.delegate) : delegate.equals(obj);
}
@Override
public String toString() {
return delegate.toString();
}
private List<T> unwrap() {
return delegate instanceof DelegateList<T> dl ? dl.unwrap() : delegate;
}
}

View File

@ -1,69 +0,0 @@
package io.gitlab.jfronny.gson.compile.processor.util;
import java.util.*;
public class ValUtils {
public static <K, V> Map<K, V> mapOf() {
return new LinkedHashMap<>();
}
public static <K, V> Map<K, V> mapOf(K k1, V v1) {
Map<K, V> map = mapOf();
map.put(k1, v1);
return map;
}
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2) {
Map<K, V> map = mapOf(k1, v1);
map.put(k2, v2);
return map;
}
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3) {
Map<K, V> map = mapOf(k1, v1, k2, v2);
map.put(k3, v3);
return map;
}
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
Map<K, V> map = mapOf(k1, v1, k2, v2, k3, v3);
map.put(k4, v4);
return map;
}
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
Map<K, V> map = mapOf(k1, v1, k2, v2, k3, v3, k4, v4);
map.put(k5, v5);
return map;
}
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
Map<K, V> map = mapOf(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5);
map.put(k6, v6);
return map;
}
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
Map<K, V> map = mapOf(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6);
map.put(k7, v7);
return map;
}
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) {
Map<K, V> map = mapOf(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7);
map.put(k8, v8);
return map;
}
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) {
Map<K, V> map = mapOf(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8);
map.put(k9, v9);
return map;
}
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) {
Map<K, V> map = mapOf(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9);
map.put(k10, v10);
return map;
}
}

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.gson.compile.processor.util.valueprocessor; package io.gitlab.jfronny.gson.compile.processor.util.valueprocessor;
import io.gitlab.jfronny.gson.compile.processor.util.DelegateList; import io.gitlab.jfronny.commons.data.delegate.DelegateList;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeKind;
@ -9,7 +9,7 @@ import javax.lang.model.util.ElementFilter;
import javax.lang.model.util.Types; import javax.lang.model.util.Types;
import java.util.*; import java.util.*;
public class Properties extends DelegateList<Property<?>> { public class Properties extends DelegateList<Property<?>, List<Property<?>>> {
public final List<Property<?>> names; public final List<Property<?>> names;
public final List<Property.Param> params; public final List<Property.Param> params;
public final List<Property.Field> fields; public final List<Property.Field> fields;