From 7d13665d4363090ba629e8575af8bce85082781f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jyri-Matti=20La=CC=88hteenma=CC=88ki?= Date: Tue, 25 Jul 2023 13:57:40 +0300 Subject: [PATCH] new functional-utils --- pom.xml | 4 +-- .../utils/meta/CommonMetadataProcessor.java | 3 +- .../java/fi/solita/utils/meta/Helpers.java | 1 + .../solita/utils/meta/MetaConstructors.java | 27 ++++++++++++++++++ .../fi/solita/utils/meta/MetaMethods.java | 28 +++++++++++++++++++ .../generators/ConstructorsAsFunctions.java | 1 - 6 files changed, 60 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 2c5b61f..611d3bc 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 fi.solita.utils meta-utils - 0.12.23 + 0.12.24 @@ -36,7 +36,7 @@ fi.solita.utils functional-utils - 0.12.29 + 0.12.37 diff --git a/src/main/java/fi/solita/utils/meta/CommonMetadataProcessor.java b/src/main/java/fi/solita/utils/meta/CommonMetadataProcessor.java index 9665f54..ed057ef 100644 --- a/src/main/java/fi/solita/utils/meta/CommonMetadataProcessor.java +++ b/src/main/java/fi/solita/utils/meta/CommonMetadataProcessor.java @@ -195,7 +195,6 @@ public boolean constructorsAsFunctionsEnabled() { }; } - @SuppressWarnings("unchecked") public List> generators() { return Arrays.>asList( InstanceFieldsAsEnum.instance, @@ -378,6 +377,7 @@ public Class getClassForMethods(int argCount) { case 33: return MetaMethods.M33.class; case 34: return MetaMethods.M34.class; case 35: return MetaMethods.M35.class; + case 36: return MetaMethods.M36.class; } throw new RuntimeException("Not implemented: F" + argCount); } @@ -426,6 +426,7 @@ public Class getClassForConstructors(int argCount) { case 33: return MetaConstructors.C33.class; case 34: return MetaConstructors.C34.class; case 35: return MetaConstructors.C35.class; + case 36: return MetaConstructors.C36.class; } throw new RuntimeException("Not implemented: F" + argCount); } diff --git a/src/main/java/fi/solita/utils/meta/Helpers.java b/src/main/java/fi/solita/utils/meta/Helpers.java index 1cb8be8..32aa52d 100644 --- a/src/main/java/fi/solita/utils/meta/Helpers.java +++ b/src/main/java/fi/solita/utils/meta/Helpers.java @@ -421,6 +421,7 @@ public boolean accept(Element candidate) { }; public static final Predicate nonGeneratedElements = new Predicate() { + @SuppressWarnings("unchecked") @Override public boolean accept(Element candidate) { return candidate.getAnnotation(Helpers.GENERATED) == null; diff --git a/src/main/java/fi/solita/utils/meta/MetaConstructors.java b/src/main/java/fi/solita/utils/meta/MetaConstructors.java index 2cb8079..e7e9e24 100644 --- a/src/main/java/fi/solita/utils/meta/MetaConstructors.java +++ b/src/main/java/fi/solita/utils/meta/MetaConstructors.java @@ -39,6 +39,7 @@ import fi.solita.utils.functional.Function33; import fi.solita.utils.functional.Function34; import fi.solita.utils.functional.Function35; +import fi.solita.utils.functional.Function36; import fi.solita.utils.functional.Function4; import fi.solita.utils.functional.Function5; import fi.solita.utils.functional.Function6; @@ -74,6 +75,7 @@ import fi.solita.utils.functional.Tuple33; import fi.solita.utils.functional.Tuple34; import fi.solita.utils.functional.Tuple35; +import fi.solita.utils.functional.Tuple36; import fi.solita.utils.functional.Tuple4; import fi.solita.utils.functional.Tuple5; import fi.solita.utils.functional.Tuple6; @@ -976,4 +978,29 @@ public String toString() { return doToString(clazz, argClasses); } } + + public static abstract class C36 extends Function36 implements MetaConstructor,R> { + private transient Constructor $r; + private final Class clazz; + private final Class[] argClasses; + public C36(Class clazz, Class... argClasses) { + this.clazz = clazz; + this.argClasses = argClasses; + } + @Override + public List> getConstructorParameterTypes() { + return Collections.unmodifiableList(Arrays.asList(argClasses)); + } + @Override + public Constructor getMember() { + if ($r == null) { + $r = doGetMember(clazz, argClasses); + } + return $r; + } + @Override + public String toString() { + return doToString(clazz, argClasses); + } + } } \ No newline at end of file diff --git a/src/main/java/fi/solita/utils/meta/MetaMethods.java b/src/main/java/fi/solita/utils/meta/MetaMethods.java index ef50c2e..1453c56 100644 --- a/src/main/java/fi/solita/utils/meta/MetaMethods.java +++ b/src/main/java/fi/solita/utils/meta/MetaMethods.java @@ -33,6 +33,7 @@ import fi.solita.utils.functional.Function33; import fi.solita.utils.functional.Function34; import fi.solita.utils.functional.Function35; +import fi.solita.utils.functional.Function36; import fi.solita.utils.functional.Function4; import fi.solita.utils.functional.Function5; import fi.solita.utils.functional.Function6; @@ -67,6 +68,7 @@ import fi.solita.utils.functional.Tuple33; import fi.solita.utils.functional.Tuple34; import fi.solita.utils.functional.Tuple35; +import fi.solita.utils.functional.Tuple36; import fi.solita.utils.functional.Tuple4; import fi.solita.utils.functional.Tuple5; import fi.solita.utils.functional.Tuple6; @@ -998,4 +1000,30 @@ public final String toString() { return doToString(clazz, name); } } + + public static abstract class M36 extends Function36 implements MetaMethod,R> { + private transient Method $r; + private final Class clazz; + private final String name; + private final Class[] argClasses; + public M36(Class clazz, String name, Class... argClasses) { + this.clazz = clazz; + this.name = name; + this.argClasses = argClasses; + } + @Override + public final Method getMember() { + if ($r == null) { + $r = doGetMember(clazz, name, argClasses); + } + return $r; + } + public final String getName() { + return name; + } + @Override + public final String toString() { + return doToString(clazz, name); + } + } } \ No newline at end of file diff --git a/src/main/java/fi/solita/utils/meta/generators/ConstructorsAsFunctions.java b/src/main/java/fi/solita/utils/meta/generators/ConstructorsAsFunctions.java index 6707c02..48f544a 100644 --- a/src/main/java/fi/solita/utils/meta/generators/ConstructorsAsFunctions.java +++ b/src/main/java/fi/solita/utils/meta/generators/ConstructorsAsFunctions.java @@ -10,7 +10,6 @@ import static fi.solita.utils.functional.Functional.mkString; import static fi.solita.utils.functional.Functional.zip; import static fi.solita.utils.functional.Functional.zipWithIndex; -import static fi.solita.utils.functional.FunctionalA.concat; import static fi.solita.utils.functional.Option.Some; import static fi.solita.utils.functional.Predicates.not; import static fi.solita.utils.meta.Helpers.boxedQualifiedName;