From d0cba064b3114238b2c8e3693023dea324a14f3b Mon Sep 17 00:00:00 2001 From: Kapralov Sergey Date: Thu, 26 Oct 2023 17:26:51 +0300 Subject: [PATCH] 58: Java 21 (#59) --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- .../src/main/resources/checkstyle.xml | 7 + build-tools/parent/pom.xml | 130 +++++++++++++++++- build-tools/pom.xml | 3 - .../codegen/cfls/CflsCompound.java | 47 +++---- .../codegen/cfls/CflsFromClassPath.java | 43 +++--- .../codegen/cfls/CflsFromPath.java | 60 ++++---- .../codegen/cfls/CflsFromPaths.java | 45 +++--- .../oo/equivalence/codegen/cn/CnCombined.java | 51 +++++++ .../oo/equivalence/codegen/cn/CnFromPath.java | 18 ++- .../oo/equivalence/codegen/cp/ClassPath.java | 4 + .../oo/equivalence/codegen/cp/CpInferred.java | 48 +++++++ .../codegen/ii/IIImplementEObjectEquals.java | 41 ++++-- .../ii/IIImplementEObjectHashCode.java | 26 ++-- .../ii/IIImplementEObjectToString.java | 26 ++-- .../codegen/matchers/AllMethodsAreFinal.java | 62 ++++++--- .../MatchEqualsTriadGenerationCandidate.java | 39 ++++++ .../matchers/ShouldBeMarkedAsEObject.java | 61 +++++--- .../codegen/matchers/AllMethodsAreFinal.java | 55 ++++++++ .../MatchEqualsTriadGenerationCandidate.java | 39 ++++++ .../matchers/ShouldBeMarkedAsEObject.java | 47 +++++++ .../codegen/matchers/package-info.java | 26 ++++ .../ii/IIImplementEObjectEqualsTest.java | 59 ++++---- .../oo/equivalence/codegen/ii/Foo3.java | 29 ++++ .../ii/IIImplementEObjectEqualsTest.java | 46 +++++++ .../equivalence/codegen/ii/package-info.java | 26 ++++ oo-equivalence/equivalence-itests/pom.xml | 99 ++++++------- .../equivalence-itests/test-cases/pom.xml | 5 +- .../itests/TestExplicitEObjects.java | 51 +++++++ .../itests/records/TestRecords.java | 86 ++++++++++++ .../itests/records/package-info.java | 26 ++++ .../equivalence/itests/sealed/TestSealed.java | 69 ++++++++++ .../itests/sealed/package-info.java | 26 ++++ .../equivalence-itests/test-module2/pom.xml | 22 +++ .../itests/abstractclasses/EObjectImpl.java | 2 +- .../abstractclasses/EObjectImplImpl.java | 2 +- .../abstractclasses/NonEObjectImpl.java | 2 +- .../abstractclasses/PlainObjectImpl.java | 2 +- .../itests/abstractclasses/package-info.java | 2 +- .../itests/classes/AbstractNode.java | 2 +- .../itests/classes/AnonymousClass.java | 2 +- .../equivalence/itests/classes/BaseNode.java | 2 +- .../equivalence/itests/classes/Counter.java | 2 +- .../equivalence/itests/classes/CounterA.java | 2 +- .../itests/classes/ExplicitEObject.java | 55 ++++++++ .../itests/classes/GenericsTest.java | 2 +- .../itests/classes/GenericsTestIface.java | 2 +- .../equivalence/itests/classes/GuestList.java | 2 +- .../itests/classes/IgnoredClass.java | 2 +- .../equivalence/itests/classes/LeafNode.java | 2 +- .../oo/equivalence/itests/classes/Node.java | 2 +- .../classes/NonHintedAbstractClass.java | 2 +- .../equivalence/itests/classes/Point2D.java | 2 +- .../equivalence/itests/classes/Point3D.java | 2 +- .../itests/classes/PublicPoint.java | 2 +- .../equivalence/itests/classes/TimeRange.java | 2 +- .../equivalence/itests/classes/TreeNode.java | 2 +- .../itests/classes/package-info.java | 2 +- .../equivalence/itests/records/TRecord.java | 29 ++++ .../equivalence/itests/records/TimeRange.java | 36 +++++ .../itests/records/package-info.java | 26 ++++ .../oo/equivalence/itests/sealed/Just.java | 46 +++++++ .../oo/equivalence/itests/sealed/Just42.java | 32 +++++ .../oo/equivalence/itests/sealed/Maybe.java | 33 +++++ .../itests/sealed/Nothingness.java | 40 ++++++ .../itests/sealed/package-info.java | 26 ++++ .../oo/equivalence/maven/plugin/BaseMojo.java | 68 +++++++-- 68 files changed, 1562 insertions(+), 301 deletions(-) create mode 100644 oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cn/CnCombined.java create mode 100644 oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cp/CpInferred.java create mode 100644 oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/MatchEqualsTriadGenerationCandidate.java create mode 100644 oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/AllMethodsAreFinal.java create mode 100644 oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/MatchEqualsTriadGenerationCandidate.java create mode 100644 oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/ShouldBeMarkedAsEObject.java create mode 100644 oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/package-info.java create mode 100644 oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/Foo3.java create mode 100644 oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEqualsTest.java create mode 100644 oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/package-info.java create mode 100644 oo-equivalence/equivalence-itests/test-cases/src/test/java/com/pragmaticobjects/oo/equivalence/itests/TestExplicitEObjects.java create mode 100644 oo-equivalence/equivalence-itests/test-cases/src/test/java16/com/pragmaticobjects/oo/equivalence/itests/records/TestRecords.java create mode 100644 oo-equivalence/equivalence-itests/test-cases/src/test/java16/com/pragmaticobjects/oo/equivalence/itests/records/package-info.java create mode 100644 oo-equivalence/equivalence-itests/test-cases/src/test/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/TestSealed.java create mode 100644 oo-equivalence/equivalence-itests/test-cases/src/test/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/package-info.java create mode 100644 oo-equivalence/equivalence-itests/test-module2/pom.xml rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImpl.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImplImpl.java (97%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/NonEObjectImpl.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/PlainObjectImpl.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/package-info.java (97%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AbstractNode.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AnonymousClass.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/BaseNode.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Counter.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/CounterA.java (97%) create mode 100644 oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/ExplicitEObject.java rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTest.java (97%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTestIface.java (97%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GuestList.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/IgnoredClass.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/LeafNode.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Node.java (97%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/NonHintedAbstractClass.java (97%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point2D.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point3D.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/PublicPoint.java (97%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TimeRange.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TreeNode.java (98%) rename oo-equivalence/equivalence-itests/{test-cases => test-module2}/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/package-info.java (97%) create mode 100644 oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/TRecord.java create mode 100644 oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/TimeRange.java create mode 100644 oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/package-info.java create mode 100644 oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Just.java create mode 100644 oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Just42.java create mode 100644 oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Maybe.java create mode 100644 oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Nothingness.java create mode 100644 oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/package-info.java diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d67b698..73c6a319 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-java@v2.3.1 with: - java-version: '11' + java-version: '20' distribution: adopt gpg-private-key: ${{secrets.GPG_SIGN}} gpg-passphrase: GPG_PASSPHRASE diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e381415..24620fa8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ '11', '17' ] + java: [ '11', '17', '20' ] name: Testing on Java ${{ matrix.Java }} steps: - uses: actions/checkout@v2 diff --git a/build-tools/checkstyle/src/main/resources/checkstyle.xml b/build-tools/checkstyle/src/main/resources/checkstyle.xml index 661ff1b3..bd9161f1 100644 --- a/build-tools/checkstyle/src/main/resources/checkstyle.xml +++ b/build-tools/checkstyle/src/main/resources/checkstyle.xml @@ -30,7 +30,14 @@ + + + + + + + diff --git a/build-tools/parent/pom.xml b/build-tools/parent/pom.xml index 68b462ec..1759759f 100644 --- a/build-tools/parent/pom.xml +++ b/build-tools/parent/pom.xml @@ -14,13 +14,13 @@ pom - multi-release-java9 src/main/java9 + [9, 99) @@ -41,6 +41,116 @@ true + + testcompile-java9 + + testCompile + + + 9 + + ${project.basedir}/src/test/java9 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + + + + + + + + + multi-release-java16 + + + src/main/java16 + + [16, 99) + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + compile-java16 + + compile + + + 16 + + ${project.basedir}/src/main/java16 + + true + + + + testcompile-java16 + + testCompile + + + 16 + + ${project.basedir}/src/test/java16 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + + + + + + + + + multi-release-java17 + + + src/main/java17 + + [17, 99) + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + compile-java17 + + compile + + + 17 + + ${project.basedir}/src/main/java17 + + true + + @@ -91,7 +201,8 @@ false plain - + @@ -162,6 +273,13 @@ report + + + + + META-INF/** + + @@ -308,9 +426,15 @@ true src/main/java + src/main/java9 + src/main/java16 + src/main/java17 src/test/java + src/test/java9 + src/test/java16 + src/test/java17 checkstyle.xml true @@ -412,4 +536,4 @@ - \ No newline at end of file + diff --git a/build-tools/pom.xml b/build-tools/pom.xml index 8f2a0de2..8d07b38b 100644 --- a/build-tools/pom.xml +++ b/build-tools/pom.xml @@ -15,13 +15,10 @@ pom - 1.8 - 1.8 8 UTF-8 - diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsCompound.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsCompound.java index 6781b18e..ac2c5a78 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsCompound.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsCompound.java @@ -29,38 +29,33 @@ import net.bytebuddy.dynamic.ClassFileLocator; /** - * {@link CflsCompound} inference; + * Source for a combined {@link ClassFileLocator}, consisting of provided parts * * @author Kapralov Sergey */ -class CflsCompoundInference implements ClassFileLocatorSource.Inference { - private final List parts; +public class CflsCompound extends CflsInferred implements ClassFileLocatorSource { + private static class Inference implements ClassFileLocatorSource.Inference { + private final List parts; - /** - * Ctor. - * - * @param parts Parts to combine - */ - public CflsCompoundInference(final List parts) { - this.parts = parts; - } + /** + * Ctor. + * + * @param parts Parts to combine + */ + public Inference(final List parts) { + this.parts = parts; + } - @Override - public final ClassFileLocatorSource classFileLocatorSource() { - return new CflsExplicit( - parts - .map(ClassFileLocatorSource::classFileLocator) - .transform(cflsl -> new ClassFileLocator.Compound(cflsl.toJavaList())) - ); + @Override + public final ClassFileLocatorSource classFileLocatorSource() { + return new CflsExplicit( + parts + .map(ClassFileLocatorSource::classFileLocator) + .transform(cflsl -> new ClassFileLocator.Compound(cflsl.toJavaList())) + ); + } } -} -/** - * Source for a combined {@link ClassFileLocator}, consisting of provided parts - * - * @author Kapralov Sergey - */ -public class CflsCompound extends CflsInferred implements ClassFileLocatorSource { /** * Ctor. * @@ -68,7 +63,7 @@ public class CflsCompound extends CflsInferred implements ClassFileLocatorSource */ public CflsCompound(List parts) { super( - new CflsCompoundInference( + new Inference( parts ) ); diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromClassPath.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromClassPath.java index cb754b5f..d92f721c 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromClassPath.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromClassPath.java @@ -28,36 +28,31 @@ import com.pragmaticobjects.oo.equivalence.codegen.cp.ClassPath; /** - * {@link CflsFromClassPath} inference. + * {@link ClassFileLocatorSource} which looks for classes in certain {@link ClassPath} * * @author Kapralov Sergey */ -class CflsFromClassPathInference implements ClassFileLocatorSource.Inference { - private final ClassPath classPath; +public class CflsFromClassPath extends CflsInferred implements ClassFileLocatorSource { + private static class Inference implements ClassFileLocatorSource.Inference { + private final ClassPath classPath; - /** - * Ctor. - * - * @param classPath {@link ClassPath} instance - */ - public CflsFromClassPathInference(final ClassPath classPath) { - this.classPath = classPath; - } + /** + * Ctor. + * + * @param classPath {@link ClassPath} instance + */ + public Inference(final ClassPath classPath) { + this.classPath = classPath; + } - @Override - public final ClassFileLocatorSource classFileLocatorSource() { - return new CflsFromPaths( - classPath.paths() - ); + @Override + public final ClassFileLocatorSource classFileLocatorSource() { + return new CflsFromPaths( + classPath.paths() + ); + } } -} -/** - * {@link ClassFileLocatorSource} which looks for classes in certain {@link ClassPath} - * - * @author Kapralov Sergey - */ -public class CflsFromClassPath extends CflsInferred implements ClassFileLocatorSource { /** * Ctor. * @@ -65,7 +60,7 @@ public class CflsFromClassPath extends CflsInferred implements ClassFileLocatorS */ public CflsFromClassPath(final ClassPath cp) { super( - new CflsFromClassPathInference( + new Inference( cp ) ); diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromPath.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromPath.java index df9d610c..cc6aa26d 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromPath.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromPath.java @@ -30,38 +30,6 @@ import java.nio.file.Files; import java.nio.file.Path; -/** - * {@link CflsFromPath} inference - * - * @author Kapralov Sergey - */ -class CflsFromPathInference implements ClassFileLocatorSource.Inference { - private final Path path; - - /** - * Ctor. - * - * @param path Path - */ - public CflsFromPathInference(final Path path) { - this.path = path; - } - - @Override - public final ClassFileLocatorSource classFileLocatorSource() { - if(!Files.exists(path)) { - return new CflsExplicit( - ClassFileLocator.NoOp.INSTANCE - ); - } - if(Files.isDirectory(path)) { - return new CflsDirectory(path); - } else { - return new CflsJar(path); - } - } -} - /** * Source for {@link net.bytebuddy.dynamic.ClassFileLocator}, made from specified path. * It automatically determines the nature of path provided (a directory or a jar file) @@ -70,6 +38,32 @@ public final ClassFileLocatorSource classFileLocatorSource() { * @author Kapralov Sergey */ public class CflsFromPath extends CflsInferred implements ClassFileLocatorSource { + private static class Inference implements ClassFileLocatorSource.Inference { + private final Path path; + + /** + * Ctor. + * + * @param path Path + */ + public Inference(final Path path) { + this.path = path; + } + + @Override + public final ClassFileLocatorSource classFileLocatorSource() { + if(!Files.exists(path)) { + return new CflsExplicit( + ClassFileLocator.NoOp.INSTANCE + ); + } + if(Files.isDirectory(path)) { + return new CflsDirectory(path); + } else { + return new CflsJar(path); + } + } + } /** * Ctor. @@ -78,7 +72,7 @@ public class CflsFromPath extends CflsInferred implements ClassFileLocatorSource */ public CflsFromPath(final Path path) { super( - new CflsFromPathInference( + new Inference( path ) ); diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromPaths.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromPaths.java index 9262b3a5..c74f579d 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromPaths.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cfls/CflsFromPaths.java @@ -29,37 +29,34 @@ import java.nio.file.Path; + /** - * {@link CflsFromPaths} inference. + * Source from {@link net.bytebuddy.dynamic.ClassFileLocator}, made from provided paths. * * @author Kapralov Sergey */ -class CflsFromPathsInference implements ClassFileLocatorSource.Inference { - private final List paths; +public class CflsFromPaths extends CflsInferred implements ClassFileLocatorSource { + private static class Inference implements ClassFileLocatorSource.Inference { + private final List paths; - /** - * Ctor. - * - * @param paths Paths - */ - public CflsFromPathsInference(final List paths) { - this.paths = paths; - } + /** + * Ctor. + * + * @param paths Paths + */ + public Inference(final List paths) { + this.paths = paths; + } - @Override - public final ClassFileLocatorSource classFileLocatorSource() { - return paths - .map(CflsFromPath::new) - .transform(CflsCompound::new); + @Override + public final ClassFileLocatorSource classFileLocatorSource() { + return paths + .map(CflsFromPath::new) + .transform(CflsCompound::new); + } } -} -/** - * Source from {@link net.bytebuddy.dynamic.ClassFileLocator}, made from provided paths. - * - * @author Kapralov Sergey - */ -public class CflsFromPaths extends CflsInferred implements ClassFileLocatorSource { + /** * Ctor. * @@ -67,7 +64,7 @@ public class CflsFromPaths extends CflsInferred implements ClassFileLocatorSourc */ public CflsFromPaths(final List paths) { super( - new CflsFromPathsInference( + new Inference( paths ) ); diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cn/CnCombined.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cn/CnCombined.java new file mode 100644 index 00000000..a273e280 --- /dev/null +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cn/CnCombined.java @@ -0,0 +1,51 @@ +/*- + * =========================================================================== + * equivalence-codegen + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.codegen.cn; + +import io.vavr.collection.List; + +/** + * Class names list, collected from multiple sources + * + * @author Kapralov Sergey + */ +public class CnCombined implements ClassNames { + private final List parts; + + /** + * Ctor. + * + * @param sources Combined class names sources + */ + public CnCombined(List sources) { + this.parts = sources; + } + + @Override + public final List classNames() { + return parts.flatMap(ClassNames::classNames); + } +} diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cn/CnFromPath.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cn/CnFromPath.java index 44ad4b79..987da441 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cn/CnFromPath.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cn/CnFromPath.java @@ -30,6 +30,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.stream.StreamSupport; /** @@ -55,13 +56,16 @@ public final List classNames() { if(Files.notExists(path)) { return List.empty(); } - final List classes = Files.find(path, Integer.MAX_VALUE, (p, bf) -> p.toString().endsWith(".class")) - .map(path::relativize) - .map(p -> List.ofAll(StreamSupport.stream(p.spliterator(), false))) - .map(pl -> pl.map(Object::toString).collect(Collectors.joining("."))) - .map(s -> s.replaceFirst(".class$", "")) - .filter(s -> !s.endsWith("module-info")) - .collect(List.collector()); + final List classes; + try(final Stream pathsStream = Files.find(path, Integer.MAX_VALUE, (p, bf) -> p.toString().endsWith(".class"))) { + classes = pathsStream.map(path::relativize) + .map(p -> List.ofAll(StreamSupport.stream(p.spliterator(), false))) + .map(pl -> pl.map(Object::toString).collect(Collectors.joining("."))) + .map(s -> s.replaceFirst(".class$", "")) + .filter(s -> !s.startsWith("META-INF") /* Multi module nested paths */) + .filter(s -> !s.endsWith("module-info")) + .collect(List.collector()); + } return classes; } catch(Exception ex) { throw new RuntimeException(ex); diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cp/ClassPath.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cp/ClassPath.java index ee13fe2f..27860e93 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cp/ClassPath.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cp/ClassPath.java @@ -34,6 +34,10 @@ * @author Kapralov Sergey */ public interface ClassPath { + interface Inference { + ClassPath classPath(); + } + /** * @return The list of paths, this class path consists of. */ diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cp/CpInferred.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cp/CpInferred.java new file mode 100644 index 00000000..920e5c5d --- /dev/null +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/cp/CpInferred.java @@ -0,0 +1,48 @@ +/*- + * =========================================================================== + * equivalence-codegen + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.codegen.cp; + +import io.vavr.collection.List; + +import java.nio.file.Path; + +/** + * Inferred {@link ClassPath} + * + * @author Kapralov Sergey + */ +public class CpInferred implements ClassPath { + private final Inference inference; + + public CpInferred(Inference inference) { + this.inference = inference; + } + + @Override + public final List paths() { + return inference.classPath().paths(); + } +} diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEquals.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEquals.java index 9d659828..2ade64ee 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEquals.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEquals.java @@ -28,6 +28,7 @@ import com.pragmaticobjects.oo.equivalence.base.EObject; import com.pragmaticobjects.oo.equivalence.base.EquivalenceLogic; import com.pragmaticobjects.oo.equivalence.codegen.ii.bb.Implementation; +import com.pragmaticobjects.oo.equivalence.codegen.matchers.MatchEqualsTriadGenerationCandidate; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.dynamic.DynamicType; @@ -36,6 +37,7 @@ import net.bytebuddy.implementation.bytecode.member.MethodReturn; import net.bytebuddy.implementation.bytecode.member.MethodVariableAccess; import net.bytebuddy.jar.asm.Opcodes; +import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +47,7 @@ public class IIImplementEObjectEquals implements InstrumentationIteration { private static final Logger log = LoggerFactory.getLogger(IIImplementEObjectEquals.class); private static final Method EQLOGIC_EQUALS; - + private static final ElementMatcher GENERATION_CANDIDATE = new MatchEqualsTriadGenerationCandidate(); static { try { EQLOGIC_EQUALS = EquivalenceLogic.class.getDeclaredMethod( @@ -61,17 +63,10 @@ public class IIImplementEObjectEquals implements InstrumentationIteration { @Override public final DynamicType.Builder apply(DynamicType.Builder builder, TypeDescription typeDescription) { log.debug("equals() " + typeDescription.getActualName()); - if(!ElementMatchers.is(Object.class).matches(typeDescription.getSuperClass())) { + if(!GENERATION_CANDIDATE.matches(typeDescription)) { log.debug("Skipping for non-base class"); return builder; } - if(!typeDescription.getDeclaredMethods() - .filter(ElementMatchers.named("equals")) - .filter(ElementMatchers.takesArguments(1)) - .isEmpty()) { - // If for some reason the method is already defined, we fail - throw new RuntimeException("Defining equals() for this class is unexpected"); - } final int modifiers = Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL; final StackManipulation impl = new StackManipulation.Compound( MethodVariableAccess.REFERENCE.loadFrom(0), @@ -79,10 +74,28 @@ public final DynamicType.Builder apply(DynamicType.Builder builder, TypeDe MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(EQLOGIC_EQUALS)), MethodReturn.INTEGER ); - return builder - .defineMethod("equals", boolean.class, modifiers) - .withParameters(Object.class) - .intercept(new Implementation(impl)) - .annotateMethod(new GeneratedMark()); + if(!typeDescription.getDeclaredMethods() + .filter(ElementMatchers.named("equals")) + .filter(ElementMatchers.takesArguments(1)) + .isEmpty() + ) { + if(typeDescription.isRecord()) { + log.debug("defining equals for record"); + return builder + .method(ElementMatchers.named("equals")) + .intercept(new Implementation(impl)) + .annotateMethod(new GeneratedMark(), new OverrideMark()); + } else { + // If for some reason the method is already defined, we fail + throw new RuntimeException("Defining equals() for this class is unexpected"); + } + } else { + log.debug("defining equals for record 2"); + return builder + .defineMethod("equals", boolean.class, modifiers) + .withParameters(Object.class) + .intercept(new Implementation(impl)) + .annotateMethod(new GeneratedMark()); + } } } diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectHashCode.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectHashCode.java index 958d53ff..36acd295 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectHashCode.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectHashCode.java @@ -28,6 +28,7 @@ import com.pragmaticobjects.oo.equivalence.base.EObject; import com.pragmaticobjects.oo.equivalence.base.EquivalenceLogic; import com.pragmaticobjects.oo.equivalence.codegen.ii.bb.Implementation; +import com.pragmaticobjects.oo.equivalence.codegen.matchers.MatchEqualsTriadGenerationCandidate; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.dynamic.DynamicType; @@ -36,6 +37,7 @@ import net.bytebuddy.implementation.bytecode.member.MethodReturn; import net.bytebuddy.implementation.bytecode.member.MethodVariableAccess; import net.bytebuddy.jar.asm.Opcodes; +import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +47,7 @@ public class IIImplementEObjectHashCode implements InstrumentationIteration { private static final Logger log = LoggerFactory.getLogger(IIImplementEObjectHashCode.class); private static final Method EQLOGIC_HASHCODE; + private static final ElementMatcher GENERATION_CANDIDATE = new MatchEqualsTriadGenerationCandidate(); static { try { @@ -60,23 +63,30 @@ public class IIImplementEObjectHashCode implements InstrumentationIteration { @Override public final DynamicType.Builder apply(DynamicType.Builder builder, TypeDescription typeDescription) { log.debug("hashCode() " + typeDescription.getActualName()); - if(!ElementMatchers.is(Object.class).matches(typeDescription.getSuperClass())) { + if(!GENERATION_CANDIDATE.matches(typeDescription)) { log.debug("Skipping for non-base class"); return builder; } - if(!typeDescription.getDeclaredMethods() - .filter(ElementMatchers.named("hashCode")) - .filter(ElementMatchers.takesArguments(0)) - .isEmpty()) { - // If for some reason the method is already defined, we fail - throw new RuntimeException("Defining hashCode() for this class is unexpected"); - } final int modifiers = Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL; final StackManipulation impl = new StackManipulation.Compound( MethodVariableAccess.REFERENCE.loadFrom(0), MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(EQLOGIC_HASHCODE)), MethodReturn.INTEGER ); + if(!typeDescription.getDeclaredMethods() + .filter(ElementMatchers.named("hashCode")) + .filter(ElementMatchers.takesArguments(0)) + .isEmpty()) { + if(typeDescription.isRecord()) { + return builder + .method(ElementMatchers.named("hashCode")) + .intercept(new Implementation(impl)) + .annotateMethod(new GeneratedMark(), new OverrideMark()); + } else { + // If for some reason the method is already defined, we fail + throw new RuntimeException("Defining hashCode() for this class is unexpected"); + } + } return builder .defineMethod("hashCode", int.class, modifiers) .intercept(new Implementation(impl)) diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectToString.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectToString.java index 38fb8b24..a21df3d1 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectToString.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectToString.java @@ -28,6 +28,7 @@ import com.pragmaticobjects.oo.equivalence.base.EObject; import com.pragmaticobjects.oo.equivalence.base.EquivalenceLogic; import com.pragmaticobjects.oo.equivalence.codegen.ii.bb.Implementation; +import com.pragmaticobjects.oo.equivalence.codegen.matchers.MatchEqualsTriadGenerationCandidate; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.dynamic.DynamicType; @@ -36,6 +37,7 @@ import net.bytebuddy.implementation.bytecode.member.MethodReturn; import net.bytebuddy.implementation.bytecode.member.MethodVariableAccess; import net.bytebuddy.jar.asm.Opcodes; +import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +47,7 @@ public class IIImplementEObjectToString implements InstrumentationIteration { private static final Logger log = LoggerFactory.getLogger(IIImplementEObjectToString.class); private static final Method EQLOGIC_TOSTRING; + private static final ElementMatcher GENERATION_CANDIDATE = new MatchEqualsTriadGenerationCandidate(); static { try { @@ -60,23 +63,30 @@ public class IIImplementEObjectToString implements InstrumentationIteration { @Override public final DynamicType.Builder apply(DynamicType.Builder builder, TypeDescription typeDescription) { log.debug("toString() " + typeDescription.getActualName()); - if(!ElementMatchers.is(Object.class).matches(typeDescription.getSuperClass())) { + if(!GENERATION_CANDIDATE.matches(typeDescription)) { log.debug("Skipping for non-base class"); return builder; } - if(!typeDescription.getDeclaredMethods() - .filter(ElementMatchers.named("toString")) - .filter(ElementMatchers.takesArguments(0)) - .isEmpty()) { - // If for some reason the method is already defined, we fail - throw new RuntimeException("Defining toString() for this class is unexpected"); - } final int modifiers = Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL; final StackManipulation impl = new StackManipulation.Compound( MethodVariableAccess.REFERENCE.loadFrom(0), MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(EQLOGIC_TOSTRING)), MethodReturn.REFERENCE ); + if(!typeDescription.getDeclaredMethods() + .filter(ElementMatchers.named("toString")) + .filter(ElementMatchers.takesArguments(0)) + .isEmpty()) { + if(typeDescription.isRecord()) { + return builder + .method(ElementMatchers.named("toString")) + .intercept(new Implementation(impl)) + .annotateMethod(new GeneratedMark(), new OverrideMark()); + } else { + // If for some reason the method is already defined, we fail + throw new RuntimeException("Defining toString() for this class is unexpected"); + } + } return builder .defineMethod("toString", String.class, modifiers) .intercept(new Implementation(impl)) diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/AllMethodsAreFinal.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/AllMethodsAreFinal.java index 63c0b039..b761c03b 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/AllMethodsAreFinal.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/AllMethodsAreFinal.java @@ -30,40 +30,46 @@ import net.bytebuddy.description.method.MethodList; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; +import net.bytebuddy.matcher.ElementMatchers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.function.Function; + import static net.bytebuddy.matcher.ElementMatchers.*; -/** - * Matcher which matches types, methods of which are final. - * - * @author Kapralov Sergey - */ -public class AllMethodsAreFinal implements ElementMatcher { +class AllMethodsAreFinalExcept implements ElementMatcher { private static final Logger LOG = LoggerFactory.getLogger(AllMethodsAreFinal.class); - + + private final Function> exceptions; + + public AllMethodsAreFinalExcept(Function> exceptions) { + this.exceptions = exceptions; + } + @Override public final boolean matches(TypeDescription target) { + ElementMatcher exceptionsMatcher = exceptions.apply(target); MethodList methodsToCheck = target.getDeclaredMethods() - .filter(not(isConstructor())) - .filter( - new ConjunctionMatcher<>( - List.of( + .filter(not(isConstructor())) + .filter( + new ConjunctionMatcher<>( + List.of( isPublic(), - not(named("attributes")), - not(named("baseType")), - not(named("hashSeed")) - ) + not(named("attributes")), + not(named("baseType")), + not(named("hashSeed")) ) ) - .filter(not(isStatic())) - .filter(not(isAbstract())) - .filter(not(isBridge())) - .filter(not(named("equals"))) - .filter(not(named("hashCode"))) - .filter(not(named("toString"))); - + ) + .filter(not(isStatic())) + .filter(not(isAbstract())) + .filter(not(isBridge())) + .filter(not(exceptionsMatcher)) + .filter(not(named("equals"))) + .filter(not(named("hashCode"))) + .filter(not(named("toString"))); + for(MethodDescription md : methodsToCheck) { LOG.debug(md.getDeclaringType().getActualName() + "::" + md.getName()); if(!md.isFinal()) { @@ -75,3 +81,15 @@ public final boolean matches(TypeDescription target) { return true; } } + + +/** + * Matcher which matches types, methods of which are final. + * + * @author Kapralov Sergey + */ +public class AllMethodsAreFinal extends AllMethodsAreFinalExcept { + public AllMethodsAreFinal() { + super(target -> ElementMatchers.none()); + } +} diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/MatchEqualsTriadGenerationCandidate.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/MatchEqualsTriadGenerationCandidate.java new file mode 100644 index 00000000..b95eb889 --- /dev/null +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/MatchEqualsTriadGenerationCandidate.java @@ -0,0 +1,39 @@ +/*- + * =========================================================================== + * equivalence-codegen + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.codegen.matchers; + +import net.bytebuddy.matcher.ElementMatchers; + +/** + * Matches classes, where equals/hashCode/toString methods should be generated by instrumenter + * + * @author skapral + */ +public class MatchEqualsTriadGenerationCandidate extends MatchSuperClass { + public MatchEqualsTriadGenerationCandidate() { + super(ElementMatchers.is(Object.class)); + } +} diff --git a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/ShouldBeMarkedAsEObject.java b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/ShouldBeMarkedAsEObject.java index d422b0bb..4fc5302f 100644 --- a/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/ShouldBeMarkedAsEObject.java +++ b/oo-equivalence/equivalence-codegen/src/main/java/com/pragmaticobjects/oo/equivalence/codegen/matchers/ShouldBeMarkedAsEObject.java @@ -29,24 +29,23 @@ import com.pragmaticobjects.oo.equivalence.base.EObjectHint; import java.lang.annotation.Annotation; import java.util.function.Function; + +import com.pragmaticobjects.oo.equivalence.base.EquivalenceCompliant; +import io.vavr.collection.List; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatchers; -/** - * Matches classes, that should be marked as EObjects. - * Semantically, "marking as EObject" means confirming that equivalence logic is applicable for the type. - * Technically, "marking as EObject" means making the class implement {@link EObject} and its methods, if necessary. - * - * Later, all {@link EObject} implementors will become candidates for instrumentation - * - * @see ShouldImplementEObjectMethods - * @author skapral - */ -public class ShouldBeMarkedAsEObject extends DisjunctionMatcher { - public ShouldBeMarkedAsEObject(Class eobjectHint, Function hintStatus) { +class DirectNonAbstractSubtypeOfObjectAttributesOfWhichAreAllFinal extends ConjunctionMatcher { + public DirectNonAbstractSubtypeOfObjectAttributesOfWhichAreAllFinal( + Class eobjectHint, + Function hintStatus + ) { super( - // direct non-abstract subtype of Object, attributes of which are all final (stand for identity) - new ConjunctionMatcher<>( + List.of( + ElementMatchers.not( + // No sense in marking the objects that already handle equivalence + ElementMatchers.isSubTypeOf(EquivalenceCompliant.class) + ), ElementMatchers.not( ElementMatchers.isAbstract() ), @@ -58,9 +57,18 @@ public ShouldBeMarkedAsEObject(Class eobjectHint ElementMatchers.not( new HasHint<>(eobjectHint, hintStatus, false) ) - ), - // or explicitly hinted class if abstract - new ConjunctionMatcher<>( + ) + ); + } +} + +class ExplicitlyHintedAbstractClass extends ConjunctionMatcher { + public ExplicitlyHintedAbstractClass( + Class eobjectHint, + Function hintStatus + ) { + super( + List.of( ElementMatchers.isAbstract(), new ConjunctionMatcher<>( new MatchSuperClass( @@ -71,6 +79,25 @@ public ShouldBeMarkedAsEObject(Class eobjectHint ) ); } +} + +/** + * Matches classes, that should be marked as EObjects. + * Semantically, "marking as EObject" means confirming that equivalence logic is applicable for the type. + * Technically, "marking as EObject" means making the class implement {@link EObject} and its methods, if necessary. + * + * Later, all {@link EObject} implementors will become candidates for instrumentation + * + * @see ShouldImplementEObjectMethods + * @author skapral + */ +public class ShouldBeMarkedAsEObject extends DisjunctionMatcher { + public ShouldBeMarkedAsEObject(Class eobjectHint, Function hintStatus) { + super( + new DirectNonAbstractSubtypeOfObjectAttributesOfWhichAreAllFinal(eobjectHint, hintStatus), + new ExplicitlyHintedAbstractClass(eobjectHint, hintStatus) + ); + } public ShouldBeMarkedAsEObject() { this(EObjectHint.class, EObjectHint::enabled); diff --git a/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/AllMethodsAreFinal.java b/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/AllMethodsAreFinal.java new file mode 100644 index 00000000..905865b0 --- /dev/null +++ b/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/AllMethodsAreFinal.java @@ -0,0 +1,55 @@ +/*- + * =========================================================================== + * equivalence-codegen + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.codegen.matchers; + +import io.vavr.collection.List; + +import static net.bytebuddy.matcher.ElementMatchers.*; + +public class AllMethodsAreFinal extends AllMethodsAreFinalExcept { + public AllMethodsAreFinal() { + super( + target -> { + boolean isRecord = isRecord().matches(target); + if (isRecord) { + return new DisjunctionMatcher<>( + target.getRecordComponents().stream() + .map( + component -> new ConjunctionMatcher<>( + List.of( + named(component.getActualName()), + returnsGeneric(component.getType()) + ) + ) + ) + .collect(List.collector()) + ); + } + return none(); + } + ); + } +} diff --git a/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/MatchEqualsTriadGenerationCandidate.java b/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/MatchEqualsTriadGenerationCandidate.java new file mode 100644 index 00000000..1507947f --- /dev/null +++ b/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/MatchEqualsTriadGenerationCandidate.java @@ -0,0 +1,39 @@ +/*- + * =========================================================================== + * equivalence-codegen + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.codegen.matchers; + +import net.bytebuddy.matcher.ElementMatchers; + +public class MatchEqualsTriadGenerationCandidate extends MatchSuperClass { + public MatchEqualsTriadGenerationCandidate() { + super( + new DisjunctionMatcher<>( + ElementMatchers.is(Record.class), + ElementMatchers.is(Object.class) + ) + ); + } +} diff --git a/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/ShouldBeMarkedAsEObject.java b/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/ShouldBeMarkedAsEObject.java new file mode 100644 index 00000000..75bc2ca9 --- /dev/null +++ b/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/ShouldBeMarkedAsEObject.java @@ -0,0 +1,47 @@ +/*- + * =========================================================================== + * equivalence-codegen + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.codegen.matchers; + +import com.pragmaticobjects.oo.equivalence.base.EObjectHint; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatchers; + +import java.lang.annotation.Annotation; +import java.util.function.Function; + +public class ShouldBeMarkedAsEObject extends DisjunctionMatcher { + public ShouldBeMarkedAsEObject(Class eobjectHint, Function hintStatus) { + super( + ElementMatchers.isRecord(), + new DirectNonAbstractSubtypeOfObjectAttributesOfWhichAreAllFinal(eobjectHint, hintStatus), + new ExplicitlyHintedAbstractClass(eobjectHint, hintStatus) + ); + } + + public ShouldBeMarkedAsEObject() { + this(EObjectHint.class, EObjectHint::enabled); + } +} diff --git a/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/package-info.java b/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/package-info.java new file mode 100644 index 00000000..a3d48a77 --- /dev/null +++ b/oo-equivalence/equivalence-codegen/src/main/java16/com/pragmaticobjects/oo/equivalence/codegen/matchers/package-info.java @@ -0,0 +1,26 @@ +/*- + * =========================================================================== + * equivalence-codegen + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.codegen.matchers; diff --git a/oo-equivalence/equivalence-codegen/src/test/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEqualsTest.java b/oo-equivalence/equivalence-codegen/src/test/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEqualsTest.java index f0a0fe00..355e47f1 100644 --- a/oo-equivalence/equivalence-codegen/src/test/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEqualsTest.java +++ b/oo-equivalence/equivalence-codegen/src/test/java/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEqualsTest.java @@ -25,39 +25,50 @@ */ package com.pragmaticobjects.oo.equivalence.codegen.ii; +import com.pragmaticobjects.oo.equivalence.assertions.Test; import com.pragmaticobjects.oo.equivalence.assertions.TestCase; import com.pragmaticobjects.oo.equivalence.assertions.TestsSuite; +import io.vavr.collection.List; import net.bytebuddy.matcher.ElementMatchers; -/** - * - * @author skapral - */ -public class IIImplementEObjectEqualsTest extends TestsSuite { - public IIImplementEObjectEqualsTest() { - super( - new TestCase( - "declares the method", - new AssertClassAfterInstrumentation( - new IIImplementEObjectEquals(), - Foo.class, + +class BaseSetForIIImplementEObjectEquals extends TestsSuite { + public static final List BASE_SET = List.of( + new TestCase( + "declares the method", + new AssertClassAfterInstrumentation( + new IIImplementEObjectEquals(), + Foo.class, + ElementMatchers.declaresMethod( + ElementMatchers.hasMethodName("equals") + ) + ) + ), + new TestCase( + "declaration is skept for non-base classes", + new AssertClassAfterInstrumentation( + new IIImplementEObjectEquals(), + Foo2.class, + ElementMatchers.not( ElementMatchers.declaresMethod( ElementMatchers.hasMethodName("equals") ) ) - ), - new TestCase( - "declaration is skept for non-base classes", - new AssertClassAfterInstrumentation( - new IIImplementEObjectEquals(), - Foo2.class, - ElementMatchers.not( - ElementMatchers.declaresMethod( - ElementMatchers.hasMethodName("equals") - ) - ) - ) ) + ) + ); + + public BaseSetForIIImplementEObjectEquals(Test... tests) { + super( + List.of(tests).prependAll(BASE_SET) ); } } + + +/** + * + * @author skapral + */ +public class IIImplementEObjectEqualsTest extends BaseSetForIIImplementEObjectEquals { +} diff --git a/oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/Foo3.java b/oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/Foo3.java new file mode 100644 index 00000000..b1ae5d0c --- /dev/null +++ b/oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/Foo3.java @@ -0,0 +1,29 @@ +/*- + * =========================================================================== + * equivalence-codegen + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.codegen.ii; + +public record Foo3() { +} diff --git a/oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEqualsTest.java b/oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEqualsTest.java new file mode 100644 index 00000000..3a37278c --- /dev/null +++ b/oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/IIImplementEObjectEqualsTest.java @@ -0,0 +1,46 @@ +/*- + * =========================================================================== + * equivalence-codegen + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.codegen.ii; + +import com.pragmaticobjects.oo.equivalence.assertions.TestCase; +import net.bytebuddy.matcher.ElementMatchers; + +public class IIImplementEObjectEqualsTest extends BaseSetForIIImplementEObjectEquals { + public IIImplementEObjectEqualsTest() { + super( + new TestCase( + "declares the method for records", + new AssertClassAfterInstrumentation( + new IIImplementEObjectEquals(), + Foo3.class, + ElementMatchers.declaresMethod( + ElementMatchers.hasMethodName("equals") + ) + ) + ) + ); + } +} diff --git a/oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/package-info.java b/oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/package-info.java new file mode 100644 index 00000000..66289700 --- /dev/null +++ b/oo-equivalence/equivalence-codegen/src/test/java16/com/pragmaticobjects/oo/equivalence/codegen/ii/package-info.java @@ -0,0 +1,26 @@ +/*- + * =========================================================================== + * equivalence-codegen + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.codegen.ii; diff --git a/oo-equivalence/equivalence-itests/pom.xml b/oo-equivalence/equivalence-itests/pom.xml index e4856019..0f9b3a0f 100644 --- a/oo-equivalence/equivalence-itests/pom.xml +++ b/oo-equivalence/equivalence-itests/pom.xml @@ -1,50 +1,51 @@ - - - 4.0.0 - - com.pragmaticobjects.oo.equivalence - oo-equivalence - 0.0.0-SNAPSHOT - - com.pragmaticobjects.oo.equivalence.itests - equivalence-itests - pom - ${project.artifactId} - - - test-cases - test-module1 - - - - - com.pragmaticobjects.oo.equivalence - equivalence-base - - - com.pragmaticobjects.oo.equivalence - equivalence-assertions - - - net.bytebuddy - byte-buddy - - - - - - - com.pragmaticobjects.oo.equivalence - equivalence-maven-plugin - ${project.version} - - - - instrument - - - - - - + + + 4.0.0 + + com.pragmaticobjects.oo.equivalence + oo-equivalence + 0.0.0-SNAPSHOT + + com.pragmaticobjects.oo.equivalence.itests + equivalence-itests + pom + ${project.artifactId} + + + test-cases + test-module1 + test-module2 + + + + + com.pragmaticobjects.oo.equivalence + equivalence-base + + + com.pragmaticobjects.oo.equivalence + equivalence-assertions + + + net.bytebuddy + byte-buddy + + + + + + + com.pragmaticobjects.oo.equivalence + equivalence-maven-plugin + ${project.version} + + + + instrument + + + + + + \ No newline at end of file diff --git a/oo-equivalence/equivalence-itests/test-cases/pom.xml b/oo-equivalence/equivalence-itests/test-cases/pom.xml index 5b9493b4..229f9cfb 100644 --- a/oo-equivalence/equivalence-itests/test-cases/pom.xml +++ b/oo-equivalence/equivalence-itests/test-cases/pom.xml @@ -9,12 +9,13 @@ test-cases jar equivalence-itests.${project.artifactId} - + com.pragmaticobjects.oo.equivalence.itests - test-module1 + test-module2 ${project.version} + test \ No newline at end of file diff --git a/oo-equivalence/equivalence-itests/test-cases/src/test/java/com/pragmaticobjects/oo/equivalence/itests/TestExplicitEObjects.java b/oo-equivalence/equivalence-itests/test-cases/src/test/java/com/pragmaticobjects/oo/equivalence/itests/TestExplicitEObjects.java new file mode 100644 index 00000000..b3039dfa --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-cases/src/test/java/com/pragmaticobjects/oo/equivalence/itests/TestExplicitEObjects.java @@ -0,0 +1,51 @@ +/*- + * =========================================================================== + * equivalence-itests.test-cases + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests; + +import com.pragmaticobjects.oo.equivalence.assertions.*; +import com.pragmaticobjects.oo.equivalence.itests.classes.ExplicitEObject; + +public class TestExplicitEObjects extends TestsSuite { + public TestExplicitEObjects() { + super( + new TestCase( + "explicit eobjects equality", + new AssertCombined( + new AssertTwoObjectsEquality( + new ExplicitEObject(new int[] {1,2,3}), + new ExplicitEObject(new int[] {1,2,3}), + true + ), + new AssertTwoObjectsEquality( + new ExplicitEObject(new int[] {1,2,3}), + new ExplicitEObject(new int[] {4,5,6}), + false + ) + ) + ) + ); + } +} diff --git a/oo-equivalence/equivalence-itests/test-cases/src/test/java16/com/pragmaticobjects/oo/equivalence/itests/records/TestRecords.java b/oo-equivalence/equivalence-itests/test-cases/src/test/java16/com/pragmaticobjects/oo/equivalence/itests/records/TestRecords.java new file mode 100644 index 00000000..5ebaf92a --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-cases/src/test/java16/com/pragmaticobjects/oo/equivalence/itests/records/TestRecords.java @@ -0,0 +1,86 @@ +/*- + * =========================================================================== + * equivalence-itests.test-cases + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.records; + +import com.pragmaticobjects.oo.equivalence.assertions.*; +import com.pragmaticobjects.oo.equivalence.itests.classes.Counter; + +import java.time.LocalDate; +import java.util.HashMap; +import java.util.Map; + +public class TestRecords extends TestsSuite { + private static final Map CONSTANT = new HashMap<>(); + + public TestRecords() { + super( + new TestCase( + "Test record with non-equivalent fields", + new AssertCombined( + new AssertEqualsResult( + new TRecord<>(CONSTANT), + new TRecord<>(CONSTANT), + true + ), + new AssertEqualsResult( + new TRecord<>(new HashMap<>()), + new TRecord<>(new HashMap<>()), + false + ) + ) + ), + new TestCase( + "Test record with equivalent fields", + new AssertCombined( + new AssertEqualsResult( + new TRecord<>(new Counter("A")), + new TRecord<>(new Counter("A")), + true + ), + new AssertEqualsResult( + new TRecord<>(new Counter("A")), + new TRecord<>(new Counter("B")), + false + ) + ) + ), + new TestCase( + "record with hinted atributtes", + new AssertTwoObjectsEquality( + new TimeRange( + LocalDate.of(2020, 1, 1), + LocalDate.of(2030, 1, 1) + ), + new TimeRange( + LocalDate.of(2020, 1, 1), + LocalDate.of(2030, 1, 1) + ), + true + ) + ) + ); + } +} diff --git a/oo-equivalence/equivalence-itests/test-cases/src/test/java16/com/pragmaticobjects/oo/equivalence/itests/records/package-info.java b/oo-equivalence/equivalence-itests/test-cases/src/test/java16/com/pragmaticobjects/oo/equivalence/itests/records/package-info.java new file mode 100644 index 00000000..66cd976b --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-cases/src/test/java16/com/pragmaticobjects/oo/equivalence/itests/records/package-info.java @@ -0,0 +1,26 @@ +/*- + * =========================================================================== + * equivalence-itests.test-cases + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.records; diff --git a/oo-equivalence/equivalence-itests/test-cases/src/test/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/TestSealed.java b/oo-equivalence/equivalence-itests/test-cases/src/test/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/TestSealed.java new file mode 100644 index 00000000..ec035da8 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-cases/src/test/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/TestSealed.java @@ -0,0 +1,69 @@ +/*- + * =========================================================================== + * equivalence-itests.test-cases + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.sealed; + +import com.pragmaticobjects.oo.equivalence.assertions.AssertCombined; +import com.pragmaticobjects.oo.equivalence.assertions.AssertEqualsResult; +import com.pragmaticobjects.oo.equivalence.assertions.TestCase; +import com.pragmaticobjects.oo.equivalence.assertions.TestsSuite; + +public class TestSealed extends TestsSuite { + public TestSealed() { + super( + new TestCase( + "Sealed interface can have equivalence-compliant implementations", + new AssertCombined( + new AssertEqualsResult( + new Just<>(1), + new Just<>(1), + true + ), + new AssertEqualsResult( + new Just<>(1), + new Just<>(2), + false + ), + new AssertEqualsResult( + new Just<>(42), + new Just42(), + true + ), + new AssertEqualsResult( + new Nothingness<>(), + new Nothingness<>(), + true + ), + new AssertEqualsResult( + new Nothingness<>(), + new Just<>(1), + false + ) + ) + ) + ); + } +} + diff --git a/oo-equivalence/equivalence-itests/test-cases/src/test/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/package-info.java b/oo-equivalence/equivalence-itests/test-cases/src/test/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/package-info.java new file mode 100644 index 00000000..03430e24 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-cases/src/test/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/package-info.java @@ -0,0 +1,26 @@ +/*- + * =========================================================================== + * equivalence-itests.test-cases + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.sealed; diff --git a/oo-equivalence/equivalence-itests/test-module2/pom.xml b/oo-equivalence/equivalence-itests/test-module2/pom.xml new file mode 100644 index 00000000..68030551 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-module2/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + com.pragmaticobjects.oo.equivalence.itests + equivalence-itests + 0.0.0-SNAPSHOT + + test-module2 + equivalence-itests.${project.artifactId} + jar + + + + com.pragmaticobjects.oo.equivalence.itests + test-module1 + ${project.version} + + + \ No newline at end of file diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImpl.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImpl.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImpl.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImpl.java index f2d0f49c..c4330ce3 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImpl.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImpl.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImplImpl.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImplImpl.java similarity index 97% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImplImpl.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImplImpl.java index 0da8fc85..d8d881c6 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImplImpl.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/EObjectImplImpl.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/NonEObjectImpl.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/NonEObjectImpl.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/NonEObjectImpl.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/NonEObjectImpl.java index 2315dbca..8a7a1831 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/NonEObjectImpl.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/NonEObjectImpl.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/PlainObjectImpl.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/PlainObjectImpl.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/PlainObjectImpl.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/PlainObjectImpl.java index 5a110b8b..71753332 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/PlainObjectImpl.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/PlainObjectImpl.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/package-info.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/package-info.java similarity index 97% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/package-info.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/package-info.java index dbc64e0e..db2fa66a 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/package-info.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/abstractclasses/package-info.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AbstractNode.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AbstractNode.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AbstractNode.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AbstractNode.java index 1d6f7d1c..606a3415 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AbstractNode.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AbstractNode.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AnonymousClass.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AnonymousClass.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AnonymousClass.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AnonymousClass.java index 6555c37d..a2981871 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AnonymousClass.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/AnonymousClass.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/BaseNode.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/BaseNode.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/BaseNode.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/BaseNode.java index ac345b82..570db8eb 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/BaseNode.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/BaseNode.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Counter.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Counter.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Counter.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Counter.java index e9543305..3b6f90a7 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Counter.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Counter.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/CounterA.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/CounterA.java similarity index 97% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/CounterA.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/CounterA.java index dd073af3..a48d9459 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/CounterA.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/CounterA.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/ExplicitEObject.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/ExplicitEObject.java new file mode 100644 index 00000000..dcfc9bb3 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/ExplicitEObject.java @@ -0,0 +1,55 @@ +/*- + * =========================================================================== + * equivalence-itests.test-module2 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.classes; + +import com.pragmaticobjects.oo.equivalence.base.EObject; + +import java.util.stream.IntStream; + + +/** + * Class, explicitly implementing EObject interface. + * Instrumentor should NOT attempt marking it again or overwriting the methods + */ +public class ExplicitEObject implements EObject { + private final int[] digits; + + public ExplicitEObject(int[] digits) { + this.digits = digits; + } + + @Override public Object[] attributes() { + return IntStream.of(digits).boxed().toArray(); + } + + @Override public int hashSeed() { + return 13; + } + + @Override public Class baseType() { + return ExplicitEObject.class; + } +} diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTest.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTest.java similarity index 97% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTest.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTest.java index f3b7713c..1dfc5b3a 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTest.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTest.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTestIface.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTestIface.java similarity index 97% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTestIface.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTestIface.java index 2bc2ad8a..c4a72fb8 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTestIface.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GenericsTestIface.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GuestList.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GuestList.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GuestList.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GuestList.java index 8261e0f0..f5caf628 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GuestList.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/GuestList.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/IgnoredClass.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/IgnoredClass.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/IgnoredClass.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/IgnoredClass.java index 9ef0bf26..43dd15f2 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/IgnoredClass.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/IgnoredClass.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/LeafNode.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/LeafNode.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/LeafNode.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/LeafNode.java index 738cacb4..10a86d5d 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/LeafNode.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/LeafNode.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Node.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Node.java similarity index 97% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Node.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Node.java index 3d9a8cf0..21360798 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Node.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Node.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/NonHintedAbstractClass.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/NonHintedAbstractClass.java similarity index 97% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/NonHintedAbstractClass.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/NonHintedAbstractClass.java index ae912bef..ab9b7174 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/NonHintedAbstractClass.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/NonHintedAbstractClass.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point2D.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point2D.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point2D.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point2D.java index 81c3b0f5..c693e139 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point2D.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point2D.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point3D.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point3D.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point3D.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point3D.java index 26947f09..881b8b7e 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point3D.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/Point3D.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/PublicPoint.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/PublicPoint.java similarity index 97% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/PublicPoint.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/PublicPoint.java index 7eacaad5..d22e261d 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/PublicPoint.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/PublicPoint.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TimeRange.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TimeRange.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TimeRange.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TimeRange.java index 20cec125..0e674ce6 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TimeRange.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TimeRange.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TreeNode.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TreeNode.java similarity index 98% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TreeNode.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TreeNode.java index ba98944a..3eaefb82 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TreeNode.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/TreeNode.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/package-info.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/package-info.java similarity index 97% rename from oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/package-info.java rename to oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/package-info.java index b017a7aa..31e9c203 100644 --- a/oo-equivalence/equivalence-itests/test-cases/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/package-info.java +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java/com/pragmaticobjects/oo/equivalence/itests/classes/package-info.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * equivalence-itests.test-cases + * equivalence-itests.test-module2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2023 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/TRecord.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/TRecord.java new file mode 100644 index 00000000..b2a8bdc9 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/TRecord.java @@ -0,0 +1,29 @@ +/*- + * =========================================================================== + * equivalence-itests.test-module2 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.records; + +public record TRecord(T value) { +} diff --git a/oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/TimeRange.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/TimeRange.java new file mode 100644 index 00000000..a7b47326 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/TimeRange.java @@ -0,0 +1,36 @@ +/*- + * =========================================================================== + * equivalence-itests.test-module2 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.records; + +import com.pragmaticobjects.oo.equivalence.base.EquivalenceHint; + +import java.time.LocalDate; + +public record TimeRange( + @EquivalenceHint(enabled = true) LocalDate beginDate, + @EquivalenceHint(enabled = true) LocalDate endDate +) { +} diff --git a/oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/package-info.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/package-info.java new file mode 100644 index 00000000..f049221a --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java16/com/pragmaticobjects/oo/equivalence/itests/records/package-info.java @@ -0,0 +1,26 @@ +/*- + * =========================================================================== + * equivalence-itests.test-module2 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.records; diff --git a/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Just.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Just.java new file mode 100644 index 00000000..d794a1c9 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Just.java @@ -0,0 +1,46 @@ +/*- + * =========================================================================== + * equivalence-itests.test-module2 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.sealed; + +import java.util.Optional; + +public non-sealed class Just implements Maybe { + private final T value; + + public Just(T value) { + this.value = value; + } + + @Override + public final T get() { + return value; + } + + @Override + public final Optional tryGetting() { + return Optional.of(value); + } +} diff --git a/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Just42.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Just42.java new file mode 100644 index 00000000..d0b90608 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Just42.java @@ -0,0 +1,32 @@ +/*- + * =========================================================================== + * equivalence-itests.test-module2 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.sealed; + +public class Just42 extends Just { + public Just42() { + super(42); + } +} diff --git a/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Maybe.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Maybe.java new file mode 100644 index 00000000..972f6547 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Maybe.java @@ -0,0 +1,33 @@ +/*- + * =========================================================================== + * equivalence-itests.test-module2 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.sealed; + +import java.util.Optional; + +public sealed interface Maybe permits Just, Nothingness { + T get(); + Optional tryGetting(); +} diff --git a/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Nothingness.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Nothingness.java new file mode 100644 index 00000000..70d91e11 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/Nothingness.java @@ -0,0 +1,40 @@ +/*- + * =========================================================================== + * equivalence-itests.test-module2 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.sealed; + +import java.util.Optional; + +public non-sealed class Nothingness implements Maybe { + @Override + public final T get() { + return null; + } + + @Override + public final Optional tryGetting() { + return Optional.empty(); + } +} diff --git a/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/package-info.java b/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/package-info.java new file mode 100644 index 00000000..6f48a2d2 --- /dev/null +++ b/oo-equivalence/equivalence-itests/test-module2/src/main/java17/com/pragmaticobjects/oo/equivalence/itests/sealed/package-info.java @@ -0,0 +1,26 @@ +/*- + * =========================================================================== + * equivalence-itests.test-module2 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Copyright (C) 2019 - 2023 Kapralov Sergey + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * ============================================================================ + */ +package com.pragmaticobjects.oo.equivalence.itests.sealed; diff --git a/oo-equivalence/equivalence-maven-plugin/src/main/java/com/pragmaticobjects/oo/equivalence/maven/plugin/BaseMojo.java b/oo-equivalence/equivalence-maven-plugin/src/main/java/com/pragmaticobjects/oo/equivalence/maven/plugin/BaseMojo.java index 0ec87890..c491bfac 100644 --- a/oo-equivalence/equivalence-maven-plugin/src/main/java/com/pragmaticobjects/oo/equivalence/maven/plugin/BaseMojo.java +++ b/oo-equivalence/equivalence-maven-plugin/src/main/java/com/pragmaticobjects/oo/equivalence/maven/plugin/BaseMojo.java @@ -25,13 +25,15 @@ */ package com.pragmaticobjects.oo.equivalence.maven.plugin; -import com.pragmaticobjects.oo.equivalence.codegen.cn.CnExcludingPackages; import com.pragmaticobjects.oo.equivalence.codegen.cn.CnFromPath; import com.pragmaticobjects.oo.equivalence.codegen.cp.ClassPath; +import com.pragmaticobjects.oo.equivalence.codegen.cp.CpCombined; +import com.pragmaticobjects.oo.equivalence.codegen.cp.CpExplicit; import com.pragmaticobjects.oo.equivalence.codegen.cp.CpFromString; import com.pragmaticobjects.oo.equivalence.codegen.instrumentation.ApplyStages; import com.pragmaticobjects.oo.equivalence.codegen.stage.Stage; import io.vavr.collection.HashSet; +import io.vavr.collection.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -41,8 +43,11 @@ import org.apache.maven.project.MavenProject; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Base Mojo for different instrumentations @@ -58,26 +63,65 @@ public abstract class BaseMojo extends AbstractMojo { protected final ClassPath buildClassPath() { PluginDescriptor pluginDescriptor = (PluginDescriptor) this.getPluginContext().get("pluginDescriptor"); String classPath = HashSet.ofAll(project.getArtifacts()) - .addAll(pluginDescriptor.getArtifacts()) - .map(Artifact::getFile) - .map(File::toString) - .collect(Collectors.joining(";")); + .addAll(pluginDescriptor.getArtifacts()) + .map(Artifact::getFile) + .map(File::toString) + .collect(Collectors.joining(";")); ClassPath cp = new CpFromString(classPath); return cp; } - - protected final void doInstrumentation(Stage stage, ClassPath cp, Path workingDirectory) throws MojoExecutionException, MojoFailureException { - if(!project.getPackaging().equals("pom") || instrumentPomProjects) { + + + protected final List multiReleaseWorkingSubdirectories(Path workingDirectory) { + final List multiReleaseWorkingSubdirectories; + final Path multiReleaseVersionsPath = workingDirectory.resolve("META-INF/versions"); + if (Files.exists(multiReleaseVersionsPath)) { + try (Stream stream = Files.find( + multiReleaseVersionsPath, + 1, + (p, bf) -> !multiReleaseVersionsPath.equals(p) && Files.isDirectory(p) + )) { + multiReleaseWorkingSubdirectories = stream.collect(List.collector()); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } else { + multiReleaseWorkingSubdirectories = List.empty(); + } + return multiReleaseWorkingSubdirectories; + } + + protected final void doInstrumentation( + Stage stage, + ClassPath cp, + Path workingDirectory + ) throws MojoExecutionException, MojoFailureException { + if (!project.getPackaging().equals("pom") || instrumentPomProjects) { new ApplyStages( cp, workingDirectory, - new CnExcludingPackages( - new CnFromPath( - workingDirectory - ) + new CnFromPath( + workingDirectory ), stage ).apply(); + + final List multiReleaseSubdirs = multiReleaseWorkingSubdirectories(workingDirectory); + for (final Path workingSubdir : multiReleaseSubdirs) { + new ApplyStages( + new CpCombined( + new CpExplicit( + workingDirectory + ), + cp + ), + workingSubdir, + new CnFromPath( + workingSubdir + ), + stage + ).apply(); + } } } }