├── .appveyor.yml
├── .gitbugtraq
├── .gitignore
├── .idea
├── .gitignore
├── copyright
│ └── Apache_2_0.xml
├── encodings.xml
├── externalDependencies.xml
├── kotlinScripting.xml
├── kotlinc.xml
└── vcs.xml
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.gradle.kts
├── docs
├── EXTRA.md
├── Q-and-A.md
├── USAGE.md
└── UniListsBenchmark-results.txt
├── gradle.properties
├── gradle
├── LICENSE_HEADER
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── lombok.config
├── settings.gradle.kts
└── subprojects
├── api
├── pl.tlinkowski.unij.api
│ ├── pl.tlinkowski.unij.api.gradle.kts
│ └── src
│ │ ├── jmh
│ │ └── java
│ │ │ └── pl
│ │ │ └── tlinkowski
│ │ │ └── unij
│ │ │ └── api
│ │ │ └── UniListsBenchmark.java
│ │ ├── main
│ │ └── java
│ │ │ ├── module-info.java
│ │ │ └── pl
│ │ │ └── tlinkowski
│ │ │ └── unij
│ │ │ └── api
│ │ │ ├── UniCollectors.java
│ │ │ ├── UniJ.java
│ │ │ ├── UniJException.java
│ │ │ ├── UniJLoader.java
│ │ │ ├── UniLists.java
│ │ │ ├── UniMaps.java
│ │ │ ├── UniSets.java
│ │ │ └── package-info.java
│ │ └── test
│ │ ├── groovy
│ │ └── pl
│ │ │ └── tlinkowski
│ │ │ └── unij
│ │ │ └── api
│ │ │ ├── UniCollectorsSpec.groovy
│ │ │ ├── UniJLoaderSpec.groovy
│ │ │ ├── UniListsSpec.groovy
│ │ │ ├── UniMapsSpec.groovy
│ │ │ └── UniSetsSpec.groovy
│ │ └── resources
│ │ └── META-INF
│ │ └── services
│ │ ├── pl.tlinkowski.unij.api.UniJLoaderSpec$DifferentPriorityService
│ │ ├── pl.tlinkowski.unij.api.UniJLoaderSpec$DuplicatePriorityService
│ │ └── pl.tlinkowski.unij.api.UniJLoaderSpec$UnannotatedService
└── pl.tlinkowski.unij.service.api
│ ├── pl.tlinkowski.unij.service.api.gradle.kts
│ └── src
│ └── main
│ └── java
│ ├── module-info.java
│ └── pl
│ └── tlinkowski
│ └── unij
│ └── service
│ └── api
│ ├── UniJService.java
│ ├── collect
│ ├── UnmodifiableListFactory.java
│ ├── UnmodifiableMapFactory.java
│ ├── UnmodifiableSetFactory.java
│ └── package-info.java
│ ├── misc
│ ├── MiscellaneousApiProvider.java
│ └── package-info.java
│ └── package-info.java
├── bindings
├── collect
│ ├── pl.tlinkowski.unij.service.collect.eclipse
│ │ ├── pl.tlinkowski.unij.service.collect.eclipse.gradle.kts
│ │ └── src
│ │ │ ├── main
│ │ │ └── java
│ │ │ │ ├── module-info.java
│ │ │ │ └── pl
│ │ │ │ └── tlinkowski
│ │ │ │ └── unij
│ │ │ │ └── service
│ │ │ │ └── collect
│ │ │ │ └── eclipse
│ │ │ │ ├── EclipseUnmodifiableListFactory.java
│ │ │ │ ├── EclipseUnmodifiableMapFactory.java
│ │ │ │ ├── EclipseUnmodifiableSetFactory.java
│ │ │ │ └── package-info.java
│ │ │ └── test
│ │ │ └── groovy
│ │ │ └── pl
│ │ │ └── tlinkowski
│ │ │ └── unij
│ │ │ └── service
│ │ │ └── collect
│ │ │ └── eclipse
│ │ │ ├── EclipseUnmodifiableListFactorySpec.groovy
│ │ │ ├── EclipseUnmodifiableMapFactorySpec.groovy
│ │ │ └── EclipseUnmodifiableSetFactorySpec.groovy
│ ├── pl.tlinkowski.unij.service.collect.guava
│ │ ├── pl.tlinkowski.unij.service.collect.guava.gradle.kts
│ │ └── src
│ │ │ ├── main
│ │ │ └── java
│ │ │ │ ├── module-info.java
│ │ │ │ └── pl
│ │ │ │ └── tlinkowski
│ │ │ │ └── unij
│ │ │ │ └── service
│ │ │ │ └── collect
│ │ │ │ └── guava
│ │ │ │ ├── GuavaUnmodifiableListFactory.java
│ │ │ │ ├── GuavaUnmodifiableMapFactory.java
│ │ │ │ ├── GuavaUnmodifiableSetFactory.java
│ │ │ │ └── package-info.java
│ │ │ └── test
│ │ │ └── groovy
│ │ │ └── pl
│ │ │ └── tlinkowski
│ │ │ └── unij
│ │ │ └── service
│ │ │ └── collect
│ │ │ └── guava
│ │ │ ├── GuavaUnmodifiableListFactorySpec.groovy
│ │ │ ├── GuavaUnmodifiableMapFactorySpec.groovy
│ │ │ └── GuavaUnmodifiableSetFactorySpec.groovy
│ ├── pl.tlinkowski.unij.service.collect.jdk10
│ │ ├── pl.tlinkowski.unij.service.collect.jdk10.gradle.kts
│ │ └── src
│ │ │ ├── main
│ │ │ └── java
│ │ │ │ ├── module-info.java
│ │ │ │ └── pl
│ │ │ │ └── tlinkowski
│ │ │ │ └── unij
│ │ │ │ └── service
│ │ │ │ └── collect
│ │ │ │ └── jdk10
│ │ │ │ ├── Jdk10UnmodifiableListFactory.java
│ │ │ │ ├── Jdk10UnmodifiableMapFactory.java
│ │ │ │ ├── Jdk10UnmodifiableSetFactory.java
│ │ │ │ └── package-info.java
│ │ │ └── test
│ │ │ └── groovy
│ │ │ └── pl
│ │ │ └── tlinkowski
│ │ │ └── unij
│ │ │ └── service
│ │ │ └── collect
│ │ │ └── jdk10
│ │ │ ├── Jdk10UnmodifiableListFactorySpec.groovy
│ │ │ ├── Jdk10UnmodifiableMapFactorySpec.groovy
│ │ │ └── Jdk10UnmodifiableSetFactorySpec.groovy
│ └── pl.tlinkowski.unij.service.collect.jdk8
│ │ ├── pl.tlinkowski.unij.service.collect.jdk8.gradle.kts
│ │ └── src
│ │ ├── main
│ │ └── java
│ │ │ ├── module-info.java
│ │ │ └── pl
│ │ │ └── tlinkowski
│ │ │ └── unij
│ │ │ └── service
│ │ │ └── collect
│ │ │ └── jdk8
│ │ │ ├── Jdk8UnmodifiableListFactory.java
│ │ │ ├── Jdk8UnmodifiableMapFactory.java
│ │ │ ├── Jdk8UnmodifiableSetFactory.java
│ │ │ └── package-info.java
│ │ └── test
│ │ └── groovy
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── service
│ │ └── collect
│ │ └── jdk8
│ │ ├── Jdk8UnmodifiableListFactorySpec.groovy
│ │ ├── Jdk8UnmodifiableMapFactorySpec.groovy
│ │ └── Jdk8UnmodifiableSetFactorySpec.groovy
└── misc
│ ├── pl.tlinkowski.unij.service.misc.jdk11
│ ├── pl.tlinkowski.unij.service.misc.jdk11.gradle.kts
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ ├── module-info.java
│ │ │ └── pl
│ │ │ └── tlinkowski
│ │ │ └── unij
│ │ │ └── service
│ │ │ └── misc
│ │ │ └── jdk11
│ │ │ ├── Jdk11MiscellaneousApiProvider.java
│ │ │ └── package-info.java
│ │ └── test
│ │ └── groovy
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── service
│ │ └── misc
│ │ └── jdk11
│ │ └── Jdk11MiscellaneousApiProviderSpec.groovy
│ └── pl.tlinkowski.unij.service.misc.jdk8
│ ├── pl.tlinkowski.unij.service.misc.jdk8.gradle.kts
│ └── src
│ ├── main
│ └── java
│ │ ├── module-info.java
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── service
│ │ └── misc
│ │ └── jdk8
│ │ ├── Jdk8MiscellaneousApiProvider.java
│ │ └── package-info.java
│ └── test
│ └── groovy
│ └── pl
│ └── tlinkowski
│ └── unij
│ └── service
│ └── misc
│ └── jdk8
│ └── Jdk8MiscellaneousApiProviderSpec.groovy
├── bundles
├── pl.tlinkowski.unij.bundle.eclipse_jdk8
│ ├── pl.tlinkowski.unij.bundle.eclipse_jdk8.gradle.kts
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── module-info.java
│ │ └── test
│ │ └── groovy
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── bundle
│ │ └── eclipse_jdk8
│ │ └── EclipseJdk8BundleTest.groovy
├── pl.tlinkowski.unij.bundle.guava_jdk8
│ ├── pl.tlinkowski.unij.bundle.guava_jdk8.gradle.kts
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── module-info.java
│ │ └── test
│ │ └── groovy
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── bundle
│ │ └── guava_jdk8
│ │ └── GuavaJdk8BundleTest.groovy
├── pl.tlinkowski.unij.bundle.jdk11
│ ├── pl.tlinkowski.unij.bundle.jdk11.gradle.kts
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── module-info.java
│ │ └── test
│ │ └── groovy
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── bundle
│ │ └── jdk11
│ │ └── Jdk11BundleTest.groovy
└── pl.tlinkowski.unij.bundle.jdk8
│ ├── pl.tlinkowski.unij.bundle.jdk8.gradle.kts
│ └── src
│ ├── main
│ └── java
│ │ └── module-info.java
│ └── test
│ └── groovy
│ └── pl
│ └── tlinkowski
│ └── unij
│ └── bundle
│ └── jdk8
│ └── Jdk8BundleTest.groovy
├── pl.tlinkowski.unij.test
├── pl.tlinkowski.unij.test.gradle.kts
└── src
│ └── main
│ └── groovy
│ └── pl
│ └── tlinkowski
│ └── unij
│ └── test
│ ├── bundle
│ ├── UniJBundleTest.groovy
│ └── package-info.java
│ └── service
│ ├── collect
│ ├── UnmodifiableCollectionSpecHelper.groovy
│ ├── UnmodifiableListFactorySpec.groovy
│ ├── UnmodifiableMapFactorySpec.groovy
│ ├── UnmodifiableMapSpecHelper.groovy
│ ├── UnmodifiableSetFactorySpec.groovy
│ └── package-info.java
│ └── misc
│ └── MiscellaneousApiProviderSpec.groovy
└── samples
├── enduser
├── pl.tlinkowski.unij.sample.enduser.jdk11
│ ├── pl.tlinkowski.unij.sample.enduser.jdk11.gradle.kts
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ ├── module-info.java
│ │ │ └── pl
│ │ │ └── tlinkowski
│ │ │ └── unij
│ │ │ └── sample
│ │ │ └── enduser
│ │ │ └── jdk11
│ │ │ ├── EndUsage.java
│ │ │ └── package-info.java
│ │ └── test
│ │ └── groovy
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── sample
│ │ └── enduser
│ │ └── jdk11
│ │ └── EndUsageSpec.groovy
└── pl.tlinkowski.unij.sample.enduser.jdk8
│ ├── pl.tlinkowski.unij.sample.enduser.jdk8.gradle.kts
│ └── src
│ ├── main
│ └── java
│ │ ├── module-info.java
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── sample
│ │ └── enduser
│ │ └── jdk8
│ │ ├── EndUsage.java
│ │ └── package-info.java
│ └── test
│ └── groovy
│ └── pl
│ └── tlinkowski
│ └── unij
│ └── sample
│ └── enduser
│ └── jdk8
│ └── EndUsageSpec.groovy
└── lib
├── pl.tlinkowski.unij.sample.lib.usage.eclipse
├── pl.tlinkowski.unij.sample.lib.usage.eclipse.gradle.kts
└── src
│ ├── main
│ └── java
│ │ ├── module-info.java
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── sample
│ │ └── lib
│ │ └── usage
│ │ └── eclipse
│ │ ├── SampleLogicMain.java
│ │ └── package-info.java
│ └── test
│ └── groovy
│ └── pl
│ └── tlinkowski
│ └── unij
│ └── sample
│ └── lib
│ └── usage
│ └── eclipse
│ └── SampleLogicSpec.groovy
├── pl.tlinkowski.unij.sample.lib.usage.guava
├── pl.tlinkowski.unij.sample.lib.usage.guava.gradle.kts
└── src
│ ├── main
│ └── java
│ │ ├── module-info.java
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── sample
│ │ └── lib
│ │ └── usage
│ │ └── guava
│ │ ├── SampleLogicMain.java
│ │ └── package-info.java
│ └── test
│ └── groovy
│ └── pl
│ └── tlinkowski
│ └── unij
│ └── sample
│ └── lib
│ └── usage
│ └── guava
│ └── SampleLogicSpec.groovy
├── pl.tlinkowski.unij.sample.lib.usage.jdk11
├── pl.tlinkowski.unij.sample.lib.usage.jdk11.gradle.kts
└── src
│ ├── main
│ └── java
│ │ ├── module-info.java
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── sample
│ │ └── lib
│ │ └── usage
│ │ └── jdk11
│ │ ├── SampleLogicMain.java
│ │ └── package-info.java
│ └── test
│ └── groovy
│ └── pl
│ └── tlinkowski
│ └── unij
│ └── sample
│ └── lib
│ └── usage
│ └── jdk11
│ └── SampleLogicSpec.groovy
├── pl.tlinkowski.unij.sample.lib.usage.jdk8
├── pl.tlinkowski.unij.sample.lib.usage.jdk8.gradle.kts
└── src
│ ├── main
│ └── java
│ │ ├── module-info.java
│ │ └── pl
│ │ └── tlinkowski
│ │ └── unij
│ │ └── sample
│ │ └── lib
│ │ └── usage
│ │ └── jdk8
│ │ ├── SampleLogicMain.java
│ │ └── package-info.java
│ └── test
│ └── groovy
│ └── pl
│ └── tlinkowski
│ └── unij
│ └── sample
│ └── lib
│ └── usage
│ └── jdk8
│ └── SampleLogicSpec.groovy
└── pl.tlinkowski.unij.sample.lib
├── pl.tlinkowski.unij.sample.lib.gradle.kts
└── src
├── main
└── java
│ ├── module-info.java
│ └── pl
│ └── tlinkowski
│ └── unij
│ └── sample
│ └── lib
│ ├── SampleLogic.java
│ └── package-info.java
└── test
└── groovy
└── pl
└── tlinkowski
└── unij
└── sample
└── lib
└── SampleLogicSpec.groovy
/.appveyor.yml:
--------------------------------------------------------------------------------
1 | # reference: https://www.appveyor.com/docs/appveyor-yml/
2 |
3 | image: Visual Studio 2017 # https://www.appveyor.com/docs/windows-images-software/
4 |
5 | version: "#{build} ({branch})"
6 |
7 | branches:
8 | except:
9 | - /^\d+\.\d+\.\d+$/ # skip builds related to addTemporaryVersionTag
10 |
11 | #region JAVA
12 | environment:
13 | matrix:
14 | - JAVA_HOME: C:\Program Files\Java\jdk12
15 |
16 | install:
17 | - SET PATH=%JAVA_HOME%\bin;%PATH
18 | - java --version
19 | #endregion
20 |
21 | #region GRADLE
22 | build_script:
23 | - gradlew.bat assemble
24 |
25 | test_script:
26 | - gradlew.bat check --stacktrace
27 |
28 | cache:
29 | - C:\Users\appveyor\.gradle
30 |
31 | on_finish:
32 | # upload test results via REST-api: https://github.com/appveyor/ci/issues/92#issuecomment-307242316
33 | - ps: |
34 | $wc = New-Object 'System.Net.WebClient'
35 | Get-ChildItem . -Name -Recurse 'TEST-*.xml' |
36 | Foreach-Object {
37 | $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $_))
38 | }
39 | #endregion
40 |
--------------------------------------------------------------------------------
/.gitbugtraq:
--------------------------------------------------------------------------------
1 | [bugtraq]
2 | url = https://github.com/tlinkowski/UniJ/issues/%BUGID%
3 | loglinkregex = "#\\d+"
4 | logregex = \\d+
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
25 | #
26 | # Gradle
27 | #
28 | .gradle
29 | build/
30 |
31 | # Ignore Gradle GUI config
32 | gradle-app.setting
33 |
34 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
35 | !gradle-wrapper.jar
36 |
37 | #
38 | # IntelliJ
39 | #
40 | *.iml
41 |
42 | #
43 | # Node.js
44 | #
45 | /node_modules/
46 | /package-lock.json
47 |
48 | #
49 | # SuperPOM
50 | #
51 | /.grenrc.yml
52 | /package.json
53 | /release.bat
54 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Source: https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
2 |
3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
4 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5 |
6 | # User-specific stuff
7 | /workspace.xml
8 | /tasks.xml
9 | /usage.statistics.xml
10 | /dictionaries
11 | /shelf
12 |
13 | # Generated files
14 | /contentModel.xml
15 |
16 | # Sensitive or high-churn files
17 | /dataSources/
18 | /dataSources.ids
19 | /dataSources.local.xml
20 | /sqlDataSources.xml
21 | /dynamic.xml
22 | /uiDesigner.xml
23 | /dbnavigator.xml
24 |
25 | # Gradle
26 | /gradle.xml
27 | /libraries
28 |
29 | # Gradle and Maven with auto-import
30 | # When using Gradle or Maven with auto-import, you should exclude module files,
31 | # since they will be recreated, and may cause churn. Uncomment if using
32 | # auto-import.
33 | /modules.xml
34 | /*.iml
35 | /modules
36 |
37 | # IntelliJ
38 | out/
39 |
40 | # Other
41 | /compiler.xml
42 | /misc.xml
43 |
44 | # SuperPOM
45 | /codeStyles/
46 | /copyright/profiles_settings.xml
47 | /inspectionProfiles/
48 |
--------------------------------------------------------------------------------
/.idea/copyright/Apache_2_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/externalDependencies.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/kotlinScripting.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk: openjdk12
3 |
4 | sudo: false # faster builds
5 |
6 | branches:
7 | except:
8 | - /^\d+\.\d+\.\d+$/ # skip builds related to addTemporaryVersionTag
9 |
10 | before_install:
11 | - chmod +x gradlew # https://stackoverflow.com/questions/33820638/travis-yml-gradlew-permission-denied/33820642#33820642
12 | - pip install --user codecov # https://github.com/codecov/codecov-python#configuration
13 |
14 | #region https://docs.travis-ci.com/user/languages/java/#caching
15 | before_cache:
16 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
17 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
18 | cache:
19 | directories:
20 | - $HOME/.gradle/caches/
21 | - $HOME/.gradle/wrapper/
22 | #endregion
23 |
24 | script:
25 | - ./gradlew check --stacktrace
26 |
27 | after_success:
28 | - codecov # https://github.com/codecov/codecov-python#configuration
29 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Releases
2 |
3 | ## Version 0.1.3
4 |
5 | Release date: 28/01/2021.
6 |
7 | ### Bug Fixes
8 |
9 | - [#55](https://github.com/tlinkowski/UniJ/issues/55): Strange error - 52 vs 53 when run on GitHub Actions
10 |
11 | ---
12 |
13 | ## Version 0.1.1
14 |
15 | Release date: 16/09/2019.
16 |
17 | ### Bug Fixes
18 |
19 | - [#53](https://github.com/tlinkowski/UniJ/issues/53): Can't sync to Maven Central
20 |
21 | ---
22 |
23 | ## Version 0.1.0
24 |
25 | Release date: 15/09/2019.
26 |
27 | ### Enhancements
28 |
29 | - [#51](https://github.com/tlinkowski/UniJ/issues/51): Add sample projects
30 | - [#50](https://github.com/tlinkowski/UniJ/issues/50): Update `pl.tlinkowski.annotation.basic` to 0.2.0
31 | - [#49](https://github.com/tlinkowski/UniJ/issues/49): Update `pl.tlinkowski.gradle.my.superpom` to 0.3.0
32 | - [#48](https://github.com/tlinkowski/UniJ/issues/48): Change artifact names to module names
33 | - [#47](https://github.com/tlinkowski/UniJ/issues/47): [unij-test] Tighten the Spock specs
34 | - [#43](https://github.com/tlinkowski/UniJ/issues/43): Enable Bintray for all subprojects
35 | - [#41](https://github.com/tlinkowski/UniJ/issues/41): Improve `unij-service-api` project to export everything under `pl.tlinkowski.unij.service.api` package
36 | - [#39](https://github.com/tlinkowski/UniJ/issues/39): Extract common `unij-bundle-*` and `unij-(collect|misc)-*` configurations to `build.gradle.kts`
37 | - [#37](https://github.com/tlinkowski/UniJ/issues/37): Apply java-library plugin in all subprojects
38 | - [#36](https://github.com/tlinkowski/UniJ/issues/36): Extract unij-service-api project
39 | - [#35](https://github.com/tlinkowski/UniJ/issues/35): Add dependency on basic-annotations
40 | - [#34](https://github.com/tlinkowski/UniJ/issues/34): Use Google's @AutoService for generating META-INF/services
41 | - [#33](https://github.com/tlinkowski/UniJ/issues/33): Apply Kordamp settings plugin
42 | - [#32](https://github.com/tlinkowski/UniJ/issues/32): Introduce "bundle" modules
43 | - [#31](https://github.com/tlinkowski/UniJ/issues/31): Architecture improvements
44 | - [#30](https://github.com/tlinkowski/UniJ/issues/30): Support logging facade & log which services get loaded by UniJ
45 | - [#29](https://github.com/tlinkowski/UniJ/issues/29): Configure code quality reporting
46 | - [#28](https://github.com/tlinkowski/UniJ/issues/28): Implement unij-misc-jdk8 module
47 | - [#27](https://github.com/tlinkowski/UniJ/issues/27): Implement unij-collect-jdk8 module
48 | - [#26](https://github.com/tlinkowski/UniJ/issues/26): Implement unij-collect-eclipse module
49 | - [#25](https://github.com/tlinkowski/UniJ/issues/25): Implement unij-collect-guava module
50 | - [#24](https://github.com/tlinkowski/UniJ/issues/24): Create MiscellaneousApiProvider and related classes
51 | - [#23](https://github.com/tlinkowski/UniJ/issues/23): Create UnmodifiableMapFactory and related classes
52 | - [#22](https://github.com/tlinkowski/UniJ/issues/22): Create UnmodifiableSetFactory and related classes
53 | - [#21](https://github.com/tlinkowski/UniJ/issues/21): Support loading priority for UniJ services
54 | - [#20](https://github.com/tlinkowski/UniJ/issues/20): Configure Javadoc generation to link external Javadocs
55 | - [#18](https://github.com/tlinkowski/UniJ/issues/18): Create UniJ service loading class
56 | - [#17](https://github.com/tlinkowski/UniJ/issues/17): Create public static UniLists and UniCollectors
57 | - [#16](https://github.com/tlinkowski/UniJ/issues/16): Create UnmodifiableListFactory and related classes
58 | - [#14](https://github.com/tlinkowski/UniJ/issues/14): Add a Gradle plugin for project details
59 | - [#13](https://github.com/tlinkowski/UniJ/issues/13): Create a JMH benchmark for direct calls vs UniJ calls
60 | - [#12](https://github.com/tlinkowski/UniJ/issues/12): Introduce JPMS modules
61 | - [#11](https://github.com/tlinkowski/UniJ/issues/11): Update README.md
62 | - [#10](https://github.com/tlinkowski/UniJ/issues/10): Configure Travis CI
63 | - [#9](https://github.com/tlinkowski/UniJ/issues/9): Add IntelliJ configuration
64 | - [#7](https://github.com/tlinkowski/UniJ/issues/7): Configure code coverage reporting
65 | - [#6](https://github.com/tlinkowski/UniJ/issues/6): Configure publishing in Gradle
66 | - [#5](https://github.com/tlinkowski/UniJ/issues/5): Configure releasing in Gradle
67 | - [#3](https://github.com/tlinkowski/UniJ/issues/3): Update Gradle to 5.2.1
68 | - [#1](https://github.com/tlinkowski/UniJ/issues/1): Add initial Gradle configuration
69 |
70 | ### Bug Fixes
71 |
72 | - [#42](https://github.com/tlinkowski/UniJ/issues/42): Fix `module-info.java` for `unij-bundle-*`
73 | - [#38](https://github.com/tlinkowski/UniJ/issues/38): The code being documented uses modules but the packages defined in [...] are in the unnamed module
74 |
--------------------------------------------------------------------------------
/docs/EXTRA.md:
--------------------------------------------------------------------------------
1 | # UniJ: Extra Information
2 |
3 | ← back to [UniJ README](../README.md)
4 |
5 | Table of Contents:
6 |
7 | - [Project Layout](#project-layout)
8 | - [Performance](#performance)
9 | - [Kotlin Interoperability](#kotlin-interoperability)
10 | - [Backport of Java 9+ to Java 8](#backport-of-java-9-to-java-8)
11 |
12 | ## Project Layout
13 |
14 | - [API](../README.md#API):
15 | - [`pl.tlinkowski.unij.api`](../subprojects/api/pl.tlinkowski.unij.api)
16 | - [`pl.tlinkowski.unij.service.api`](../subprojects/api/pl.tlinkowski.unij.service.api)
17 |
18 | - [bindings](../README.md#bindings):
19 | - `Collection` factories:
20 | - [`pl.tlinkowski.unij.service.collect.jdk8`](../subprojects/bindings/collect/pl.tlinkowski.unij.service.collect.jdk8)
21 | - [`pl.tlinkowski.unij.service.collect.jdk10`](../subprojects/bindings/collect/pl.tlinkowski.unij.service.collect.jdk10)
22 | - [`pl.tlinkowski.unij.service.collect.guava`](../subprojects/bindings/collect/pl.tlinkowski.unij.service.collect.guava)
23 | - [`pl.tlinkowski.unij.service.collect.eclipse`](../subprojects/bindings/collect/pl.tlinkowski.unij.service.collect.eclipse)
24 | - miscellaneous:
25 | - [`pl.tlinkowski.unij.service.misc.jdk8`](../subprojects/bindings/misc/pl.tlinkowski.unij.service.misc.jdk8)
26 | - [`pl.tlinkowski.unij.service.misc.jdk11`](../subprojects/bindings/misc/pl.tlinkowski.unij.service.misc.jdk11)
27 |
28 | - [bundles](../README.md#bundles):
29 | - [`pl.tlinkowski.unij.bundle.jdk8`](../subprojects/bundles/pl.tlinkowski.unij.bundle.jdk8)
30 | - [`pl.tlinkowski.unij.bundle.jdk11`](../subprojects/bundles/pl.tlinkowski.unij.bundle.jdk11)
31 | - [`pl.tlinkowski.unij.bundle.guava_jdk8`](../subprojects/bundles/pl.tlinkowski.unij.bundle.guava_jdk8)
32 | - [`pl.tlinkowski.unij.bundle.eclipse_jdk8`](../subprojects/bundles/pl.tlinkowski.unij.bundle.eclipse_jdk8)
33 |
34 | - [`pl.tlinkowski.unij.test`](../subprojects/pl.tlinkowski.unij.test)
35 | (for [custom bindings](../README.md#custom-bindings))
36 |
37 | ## Performance
38 |
39 | If you wonder how UniJ's indirection (= its two extra layers: [User API](../README.md#user-api)
40 | and [Service API](../README.md#service-api)) affects performance, the answer is short: **it effectively doesn't**.
41 |
42 | It turns out the JIT compiler simply optimizes all the indirection away.
43 |
44 | You can verify this by running a JMH benchmark
45 | ([`UniListsBenchmark`](../subprojects/api/pl.tlinkowski.unij.api/src/jmh/java/pl/tlinkowski/unij/api/UniListsBenchmark.java))
46 | where calls to `UniLists` (with a JDK 11 binding) are compared to direct JDK 11 API calls. The exact results can be
47 | found [here](UniListsBenchmark-results.txt).
48 |
49 | ## Kotlin Interoperability
50 |
51 | This library is highly interoperable with [Kotlin](https://kotlinlang.org/) thanks to being annotated with regard to:
52 |
53 | - nullability ([`@NonNullPackage`](https://github.com/tlinkowski/basic-annotations/blob/master/subprojects/pl.tlinkowski.annotation.basic/src/main/java/pl/tlinkowski/annotation/basic/NonNullPackage.java))
54 | - mutability ([`@ReadOnly`](https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-annotations-jvm/src/kotlin/annotations/jvm/ReadOnly.java))
55 |
56 | using annotations provided by [Basic Java Annotations](https://github.com/tlinkowski/basic-annotations) library.
57 |
58 | ## Backport of Java 9+ to Java 8
59 |
60 | If you're looking for a backport of Java 9+ to Java 8, you can use the following for:
61 |
62 | 1. new **APIs**: [UniJ](http://unij.tlinkowski.pl)
63 |
64 | - UniJ JDK 8 bundle ([`pl.tlinkowski.unij.bundle.jdk8`](../subprojects/bundles/pl.tlinkowski.unij.bundle.jdk8))
65 | is *effectively* a backport of **some** of the JDK 9+ APIs to JDK 8
66 | (see [End Users Stuck on JDK 8](../README.md#end-users-stuck-on-jdk-8) for details)
67 |
68 | 2. new **language features**: [Jabel](https://github.com/bsideup/jabel)
69 |
70 | - Jabel is an annotation processor that lets you use **some** language features of Java 9+
71 | while still targeting JDK 8
72 |
73 | 3. **Java Platform Module System**: [Gradle Modules Plugin](https://github.com/java9-modularity/gradle-modules-plugin)
74 |
75 | - Gradle Modules Plugin provides support for JPMS (`module-info.java`) not only to JDK 9+ projects (standard mode)
76 | but also to JDK 8 projects (special
77 | [mixed mode](https://github.com/java9-modularity/gradle-modules-plugin#compilation-to-a-specific-java-release))
78 |
79 | Together, UniJ, Jabel, and Gradle Modules Plugin may provide you with pretty good "Java 9+"-like experience
80 | while still targeting / being on JDK 8.
81 |
82 | ---
83 |
84 | ← back to [UniJ README](../README.md)
85 |
--------------------------------------------------------------------------------
/docs/UniListsBenchmark-results.txt:
--------------------------------------------------------------------------------
1 | # VM version: JDK 11.0.1, OpenJDK 64-Bit Server VM, 11.0.1+13
2 | # Warmup: 5 iterations, 10 s each
3 | # Measurement: 5 iterations, 10 s each
4 |
5 | Benchmark Mode Cnt Score Error Units
6 |
7 | UniListsBenchmark.listOf avgt 25 3,690 ± 0,243 ns/op
8 | UniListsBenchmark.uniListsOf avgt 25 3,880 ± 0,176 ns/op
9 |
10 | UniListsBenchmark.listOf1 avgt 25 5,527 ± 0,073 ns/op
11 | UniListsBenchmark.uniListsOf1 avgt 25 6,259 ± 0,139 ns/op
12 |
13 | UniListsBenchmark.listOf2 avgt 25 5,982 ± 0,034 ns/op
14 | UniListsBenchmark.uniListsOf2 avgt 25 6,944 ± 0,442 ns/op
15 |
16 | UniListsBenchmark.listOf3 avgt 25 14,634 ± 0,059 ns/op
17 | UniListsBenchmark.uniListsOf3 avgt 25 16,273 ± 0,173 ns/op
18 |
19 | UniListsBenchmark.listOf10 avgt 25 39,240 ± 0,153 ns/op
20 | UniListsBenchmark.uniListsOf10 avgt 25 38,438 ± 0,104 ns/op
21 |
22 | UniListsBenchmark.listOf20 avgt 25 74,388 ± 0,226 ns/op
23 | UniListsBenchmark.uniListsOf20 avgt 25 71,040 ± 0,209 ns/op
24 |
25 | # Run complete. Total time: 01:40:40
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Copyright 2018-2019 Tomasz Linkowski.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | group=pl.tlinkowski.unij
19 | # Release scopes: [major, minor, patch]
20 | reckon.scope=patch
21 | # Dependencies
22 | mySuperpomVersion=0.5.0
23 | basicAnnotationsVersion=0.2.0
24 | slf4jVersion=1.7.28
25 | autoServiceVersion=1.0-rc6
26 | guavaLowVersion=23.2-jre
27 | guavaHighVersion=28.1-jre
28 | eclipseCollectionsLowVersion=9.0.0
29 | eclipseCollectionsHighVersion=10.0.0
30 |
--------------------------------------------------------------------------------
/gradle/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | SPDX-License-Identifier: Apache-2.0
2 |
3 | Copyright ${copyrightYear} ${author}.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tlinkowski/UniJ/f95984072419b3a60cc20aef5bd1b0b0ceb33dc0/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/lombok.config:
--------------------------------------------------------------------------------
1 | #
2 | # https://projectlombok.org/features/configuration
3 | #
4 |
5 | ## Tell the configuration system it should stop looking for other configuration files (default: false).
6 | config.stopBubbling = true
7 |
8 | ## Generate getters and setters using only the field name (no get/set prefix) (default: false).
9 | lombok.accessors.fluent = true
10 |
11 | ## Copy these annotations to getters, setters, withers, builder-setters, etc.
12 | ## (source: https://github.com/tlinkowski/basic-annotations)
13 | lombok.copyableAnnotations += kotlin.annotations.jvm.ReadOnly
14 | lombok.copyableAnnotations += kotlin.annotations.jvm.Mutable
15 | lombok.copyableAnnotations += pl.tlinkowski.annotation.basic.NullOr
16 |
17 | ## Generate @lombok.Generated on all generated code (default: false).
18 | lombok.addLombokGeneratedAnnotation = true
19 |
20 | ## Generate a private no-args constructor for @Data and @Value (default: true).
21 | # lombok.noArgsConstructor.extraPrivate = [false | true]
22 |
23 | ## When generating equals and hashCode for classes that extend something (other than Object), either automatically take
24 | ## into account superclass implementation (call), or don't (skip), or warn and don't (warn). (default = warn).
25 | # lombok.equalsAndHashCode.callSuper = [CALL | SKIP | WARN]
26 |
27 | ## When generating toString for classes that extend something (other than Object), either automatically take
28 | ## into account superclass implementation (call), or don't (skip), or warn and don't (warn). (default = warn).
29 | # lombok.toString.callSuper = [CALL | SKIP | WARN]
30 |
31 | ## Include the field names in the generated toString method (default = true).
32 | # lombok.toString.includeFieldNames = [false | true]
33 |
34 | #
35 | # FLAG USAGE
36 | #
37 |
38 | ## Emit a warning or error if @Cleanup is used.
39 | lombok.cleanup.flagUsage = ERROR
40 |
41 | ## Emit a warning or error if @Delegate is used.
42 | lombok.delegate.flagUsage = ERROR
43 |
44 | ## Emit a warning or error if @ExtensionMethod is used.
45 | lombok.extensionMethod.flagUsage = ERROR
46 |
47 | ## Emit a warning or error if @FieldDefaults is used.
48 | lombok.fieldDefaults.flagUsage = ERROR
49 |
50 | ## Emit a warning or error if @Helper is used.
51 | lombok.helper.flagUsage = ERROR
52 |
53 | ## Emit a warning or error if @CommonsLog is used.
54 | lombok.log.apacheCommons.flagUsage = ERROR
55 |
56 | ## Emit a warning or error if @Flogger is used.
57 | lombok.log.flogger.flagUsage = ERROR
58 |
59 | ## Emit a warning or error if @Log is used.
60 | lombok.log.javaUtilLogging.flagUsage = ERROR
61 |
62 | ## Emit a warning or error if @JBossLog is used.
63 | lombok.log.jbosslog.flagUsage = ERROR
64 |
65 | ## Emit a warning or error if @Log4j is used.
66 | lombok.log.log4j.flagUsage = ERROR
67 |
68 | ## Emit a warning or error if @Log4j2 is used.
69 | lombok.log.log4j2.flagUsage = ERROR
70 |
71 | ## Emit a warning or error if @Synchronized is used.
72 | lombok.synchronized.flagUsage = ERROR
73 |
74 | ## Emit a warning or error if 'var' is used.
75 | lombok.var.flagUsage = ERROR
76 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | buildscript {
19 | repositories {
20 | mavenCentral()
21 | }
22 | dependencies {
23 | val mySuperpomVersion: String by settings // https://github.com/tlinkowski/tlinkowski-superpom
24 | classpath(group = "pl.tlinkowski.gradle.my", name = "pl.tlinkowski.gradle.my.settings", version = mySuperpomVersion)
25 | }
26 | }
27 | apply(plugin = "pl.tlinkowski.gradle.my.settings")
28 |
29 | rootProject.name = "UniJ"
30 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/pl.tlinkowski.unij.api.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | modularity.mixedJavaRelease(8)
19 |
20 | superpom.useLombok = true
21 |
22 | dependencies {
23 | val slf4jVersion: String by project // https://www.slf4j.org/
24 |
25 | implementation(project(":pl.tlinkowski.unij.service.api"))
26 | implementation(group = "org.slf4j", name = "slf4j-api", version = slf4jVersion)
27 |
28 | testImplementation(project(":pl.tlinkowski.unij.test"))
29 | testRuntimeOnly(project(":pl.tlinkowski.unij.bundle.jdk11"))
30 |
31 | jmhRuntimeOnly(project(":pl.tlinkowski.unij.bundle.jdk11"))
32 | }
33 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/src/jmh/java/pl/tlinkowski/unij/api/UniListsBenchmark.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package pl.tlinkowski.unij.api;
19 |
20 | import java.util.List;
21 | import java.util.concurrent.TimeUnit;
22 |
23 | import org.openjdk.jmh.annotations.*;
24 |
25 | /**
26 | * @author Tomasz Linkowski
27 | */
28 | @BenchmarkMode(Mode.AverageTime)
29 | @OutputTimeUnit(TimeUnit.NANOSECONDS)
30 | public class UniListsBenchmark {
31 |
32 | //region of()
33 | @Benchmark
34 | public List> listOf() {
35 | return List.of();
36 | }
37 |
38 | @Benchmark
39 | public List> uniListsOf() {
40 | return UniLists.of();
41 | }
42 | //endregion
43 |
44 | //region of(n=1)
45 | @Benchmark
46 | public List> listOf1() {
47 | return List.of(1);
48 | }
49 |
50 | @Benchmark
51 | public List> uniListsOf1() {
52 | return UniLists.of(1);
53 | }
54 | //endregion
55 |
56 | //region of(n=2)
57 | @Benchmark
58 | public List> listOf2() {
59 | return List.of(1, 2);
60 | }
61 |
62 | @Benchmark
63 | public List> uniListsOf2() {
64 | return UniLists.of(1, 2);
65 | }
66 | //endregion
67 |
68 | //region of(n=3)
69 | @Benchmark
70 | public List> listOf3() {
71 | return List.of(1, 2, 3);
72 | }
73 |
74 | @Benchmark
75 | public List> uniListsOf3() {
76 | return UniLists.of(1, 2, 3);
77 | }
78 | //endregion
79 |
80 | //region of(n=10)
81 | @Benchmark
82 | public List> listOf10() {
83 | return List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
84 | }
85 |
86 | @Benchmark
87 | public List> uniListsOf10() {
88 | return UniLists.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
89 | }
90 | //endregion
91 |
92 | //region of(n=20)
93 | @Benchmark
94 | public List> listOf20() {
95 | return List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
96 | }
97 |
98 | @Benchmark
99 | public List> uniListsOf20() {
100 | return UniLists.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
101 | }
102 | //endregion
103 | }
104 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | import pl.tlinkowski.unij.api.*;
19 | import pl.tlinkowski.unij.service.api.collect.*;
20 | import pl.tlinkowski.unij.service.api.misc.MiscellaneousApiProvider;
21 |
22 | /**
23 | * UniJ API for the end users.
24 | *
25 | * The API consists of the following static utility classes: {@link UniLists}, {@link UniSets}, {@link UniMaps}, {@link
26 | * UniCollectors}.
27 | *
28 | * @author Tomasz Linkowski
29 | * @uses UnmodifiableListFactory
30 | * @uses UnmodifiableSetFactory
31 | * @uses UnmodifiableMapFactory
32 | * @uses MiscellaneousApiProvider
33 | */
34 | module pl.tlinkowski.unij.api {
35 | exports pl.tlinkowski.unij.api;
36 |
37 | requires pl.tlinkowski.unij.service.api;
38 | requires org.slf4j;
39 |
40 | requires static pl.tlinkowski.annotation.basic;
41 | requires static lombok;
42 |
43 | uses UnmodifiableListFactory;
44 | uses UnmodifiableSetFactory;
45 | uses UnmodifiableMapFactory;
46 | uses MiscellaneousApiProvider;
47 | }
48 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/src/main/java/pl/tlinkowski/unij/api/UniCollectors.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package pl.tlinkowski.unij.api;
19 |
20 | import java.util.*;
21 | import java.util.function.*;
22 | import java.util.stream.*;
23 |
24 | import lombok.experimental.UtilityClass;
25 |
26 | /**
27 | * Provides some {@link Collector} factory methods present in {@link java.util.stream.Collectors} class.
28 | *
29 | * @author Tomasz Linkowski
30 | */
31 | @UtilityClass
32 | public final class UniCollectors {
33 |
34 | //region COLLECTIONS
35 |
36 | /**
37 | * Equivalent of {@link java.util.stream.Collectors#toUnmodifiableList()}.
38 | */
39 | public static Collector> toUnmodifiableList() {
40 | return UniJ.listFactory().collector();
41 | }
42 |
43 | /**
44 | * Equivalent of {@link java.util.stream.Collectors#toUnmodifiableSet()}.
45 | */
46 | public static Collector> toUnmodifiableSet() {
47 | return UniJ.setFactory().collector();
48 | }
49 |
50 | /**
51 | * Equivalent of {@link java.util.stream.Collectors#toUnmodifiableMap(Function, Function)}.
52 | */
53 | public static Collector> toUnmodifiableMap(
54 | Function super T, ? extends K> keyMapper, Function super T, ? extends V> valueMapper) {
55 | return UniJ.mapFactory().collector(keyMapper, valueMapper);
56 | }
57 |
58 | /**
59 | * Equivalent of {@link java.util.stream.Collectors#toUnmodifiableMap(Function, Function, BinaryOperator)}.
60 | */
61 | public static Collector> toUnmodifiableMap(
62 | Function super T, ? extends K> keyMapper, Function super T, ? extends V> valueMapper,
63 | BinaryOperator mergeFunction) {
64 | return UniJ.mapFactory().collector(keyMapper, valueMapper, mergeFunction);
65 | }
66 | //endregion
67 |
68 | //region MISCELLANEOUS
69 |
70 | /**
71 | * Equivalent of {@link Collectors#flatMapping(Function, Collector)}.
72 | */
73 | public static Collector flatMapping(
74 | Function super T, ? extends Stream extends U>> mapper, Collector super U, A, R> downstream) {
75 | return UniJ.miscProvider().flatMappingCollector(mapper, downstream);
76 | }
77 |
78 | /**
79 | * Equivalent of {@link Collectors#filtering(Predicate, Collector)}.
80 | */
81 | public static Collector filtering(Predicate super T> predicate,
82 | Collector super T, A, R> downstream) {
83 | return UniJ.miscProvider().filteringCollector(predicate, downstream);
84 | }
85 | //endregion
86 | }
87 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/src/main/java/pl/tlinkowski/unij/api/UniJ.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package pl.tlinkowski.unij.api;
19 |
20 | import lombok.Getter;
21 | import lombok.experimental.UtilityClass;
22 |
23 | import pl.tlinkowski.unij.service.api.collect.*;
24 | import pl.tlinkowski.unij.service.api.misc.MiscellaneousApiProvider;
25 |
26 | /**
27 | * @author Tomasz Linkowski
28 | */
29 | @UtilityClass
30 | final class UniJ {
31 |
32 | @Getter(lazy = true)
33 | private static final UnmodifiableListFactory listFactory = UniJLoader.load(UnmodifiableListFactory.class);
34 | @Getter(lazy = true)
35 | private static final UnmodifiableSetFactory setFactory = UniJLoader.load(UnmodifiableSetFactory.class);
36 | @Getter(lazy = true)
37 | private static final UnmodifiableMapFactory mapFactory = UniJLoader.load(UnmodifiableMapFactory.class);
38 |
39 | @Getter(lazy = true)
40 | private static final MiscellaneousApiProvider miscProvider = UniJLoader.load(MiscellaneousApiProvider.class);
41 | }
42 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/src/main/java/pl/tlinkowski/unij/api/UniJException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package pl.tlinkowski.unij.api;
19 |
20 | /**
21 | * Dedicated unchecked exception for UniJ.
22 | *
23 | * @author Tomasz Linkowski
24 | */
25 | public class UniJException extends RuntimeException {
26 |
27 | public UniJException(String message) {
28 | super(message);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/src/main/java/pl/tlinkowski/unij/api/UniJLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package pl.tlinkowski.unij.api;
19 |
20 | import java.util.*;
21 | import java.util.function.Function;
22 | import java.util.stream.Collectors;
23 |
24 | import kotlin.annotations.jvm.Mutable;
25 | import kotlin.annotations.jvm.ReadOnly;
26 | import lombok.experimental.UtilityClass;
27 | import lombok.extern.slf4j.Slf4j;
28 |
29 | import pl.tlinkowski.unij.service.api.UniJService;
30 |
31 | /**
32 | * Loads UniJ services (used internally by {@link UniJ}).
33 | *
34 | * @author Tomasz Linkowski
35 | */
36 | @UtilityClass
37 | @Slf4j
38 | final class UniJLoader {
39 |
40 | static S load(Class serviceClass) {
41 | @Mutable List services = new ArrayList<>(4);
42 | ServiceLoader.load(serviceClass).forEach(services::add);
43 | validateLoadedServices(services, serviceClass);
44 | return selectService(services, serviceClass);
45 | }
46 |
47 | private static void validateLoadedServices(@ReadOnly Collection services, Class serviceClass) {
48 | if (services.isEmpty()) {
49 | throw new UniJException(String.format(
50 | "%s service implementation not found. "
51 | + "Ensure proper pl.tlinkowski.unij.service.* dependency is on the runtime classpath/modulepath",
52 | serviceClass.getName()
53 | ));
54 | }
55 | log.debug("{} service: found {}", serviceClass.getName(), services);
56 | }
57 |
58 | private static S selectService(@ReadOnly Collection services, Class serviceClass) {
59 | return selectService(buildPriorityServiceMap(services), serviceClass);
60 | }
61 |
62 | private static S selectService(@ReadOnly SortedMap priorityServiceMap, Class serviceClass) {
63 | Integer highestPriority = priorityServiceMap.firstKey();
64 | S highestPriorityService = priorityServiceMap.get(highestPriority);
65 |
66 | log.info(
67 | "{} service: selected {} (priority={})",
68 | serviceClass.getName(), className(highestPriorityService), highestPriority
69 | );
70 | return highestPriorityService;
71 | }
72 |
73 | @ReadOnly
74 | private static SortedMap buildPriorityServiceMap(@ReadOnly Collection extends S> services) {
75 | return services.stream().collect(Collectors.toMap(
76 | UniJLoader::detectPriority, Function.identity(), UniJLoader::throwOnDuplicatePriority, TreeMap::new
77 | ));
78 | }
79 |
80 | private static int detectPriority(Object service) {
81 | UniJService uniJServiceAnn = service.getClass().getAnnotation(UniJService.class);
82 | if (uniJServiceAnn == null) {
83 | throw new UniJException(String.format(
84 | "Service implementation %s not annotated with @%s", className(service), UniJService.class.getSimpleName()
85 | ));
86 | }
87 | return uniJServiceAnn.priority();
88 | }
89 |
90 | private static S throwOnDuplicatePriority(S service1, S service2) {
91 | throw new UniJException(String.format(
92 | "%s and %s have the same priority", className(service1), className(service2)
93 | ));
94 | }
95 |
96 | private static String className(Object object) {
97 | return object.getClass().getName();
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/src/main/java/pl/tlinkowski/unij/api/UniLists.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package pl.tlinkowski.unij.api;
19 |
20 | import java.util.Collection;
21 | import java.util.List;
22 |
23 | import kotlin.annotations.jvm.ReadOnly;
24 | import lombok.experimental.UtilityClass;
25 |
26 | /**
27 | * Provides static factory methods corresponding to those present in {@link List} interface.
28 | *
29 | * @author Tomasz Linkowski
30 | */
31 | @UtilityClass
32 | public final class UniLists {
33 |
34 | //region COPY OF
35 |
36 | /**
37 | * Equivalent of {@link List#copyOf(Collection)}.
38 | */
39 | @ReadOnly
40 | public static List copyOf(@ReadOnly Collection extends E> coll) {
41 | return UniJ.listFactory().copyOf(coll);
42 | }
43 | //endregion
44 |
45 | //region OF
46 |
47 | /**
48 | * Equivalent of {@link List#of()}.
49 | */
50 | @ReadOnly
51 | public static List of() {
52 | return UniJ.listFactory().of();
53 | }
54 |
55 | /**
56 | * Equivalent of {@link List#of(Object)}.
57 | */
58 | @ReadOnly
59 | public static List of(E e1) {
60 | return UniJ.listFactory().of(e1);
61 | }
62 |
63 | /**
64 | * Equivalent of {@link List#of(Object, Object)}.
65 | */
66 | @ReadOnly
67 | public static List of(E e1, E e2) {
68 | return UniJ.listFactory().of(e1, e2);
69 | }
70 |
71 | /**
72 | * Equivalent of {@link List#of(Object, Object, Object)}.
73 | */
74 | @ReadOnly
75 | public static List of(E e1, E e2, E e3) {
76 | return UniJ.listFactory().of(e1, e2, e3);
77 | }
78 |
79 | /**
80 | * Equivalent of {@link List#of(Object, Object, Object, Object)}.
81 | */
82 | @ReadOnly
83 | public static List of(E e1, E e2, E e3, E e4) {
84 | return UniJ.listFactory().of(e1, e2, e3, e4);
85 | }
86 |
87 | /**
88 | * Equivalent of {@link List#of(Object, Object, Object, Object, Object)}.
89 | */
90 | @ReadOnly
91 | public static List of(E e1, E e2, E e3, E e4, E e5) {
92 | return UniJ.listFactory().of(e1, e2, e3, e4, e5);
93 | }
94 |
95 | /**
96 | * Equivalent of {@link List#of(Object, Object, Object, Object, Object, Object)}.
97 | */
98 | @ReadOnly
99 | public static List of(E e1, E e2, E e3, E e4, E e5, E e6) {
100 | return UniJ.listFactory().of(e1, e2, e3, e4, e5, e6);
101 | }
102 |
103 | /**
104 | * Equivalent of {@link List#of(Object, Object, Object, Object, Object, Object, Object)}.
105 | */
106 | @ReadOnly
107 | public static List of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
108 | return UniJ.listFactory().of(e1, e2, e3, e4, e5, e6, e7);
109 | }
110 |
111 | /**
112 | * Equivalent of {@link List#of(Object, Object, Object, Object, Object, Object, Object, Object)}.
113 | */
114 | @ReadOnly
115 | public static List of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
116 | return UniJ.listFactory().of(e1, e2, e3, e4, e5, e6, e7, e8);
117 | }
118 |
119 | /**
120 | * Equivalent of {@link List#of(Object, Object, Object, Object, Object, Object, Object, Object, Object)}.
121 | */
122 | @ReadOnly
123 | public static List of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
124 | return UniJ.listFactory().of(e1, e2, e3, e4, e5, e6, e7, e8, e9);
125 | }
126 |
127 | /**
128 | * Equivalent of {@link List#of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)}.
129 | */
130 | @SuppressWarnings("PMD.ExcessiveParameterList")
131 | @ReadOnly
132 | public static List of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
133 | return UniJ.listFactory().of(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
134 | }
135 |
136 | /**
137 | * Equivalent of {@link List#of(Object[])}.
138 | */
139 | @SafeVarargs
140 | @ReadOnly
141 | public static List of(E... elements) {
142 | return UniJ.listFactory().of(elements);
143 | }
144 | //endregion
145 | }
146 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/src/main/java/pl/tlinkowski/unij/api/UniSets.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package pl.tlinkowski.unij.api;
19 |
20 | import java.util.*;
21 |
22 | import kotlin.annotations.jvm.ReadOnly;
23 | import lombok.experimental.UtilityClass;
24 |
25 | /**
26 | * Provides static factory methods corresponding to those present in {@link Set} interface.
27 | *
28 | * @author Tomasz Linkowski
29 | */
30 | @UtilityClass
31 | public final class UniSets {
32 |
33 | //region COPY OF
34 |
35 | /**
36 | * Equivalent of {@link Set#copyOf(Collection)}.
37 | */
38 | @ReadOnly
39 | public static Set copyOf(@ReadOnly Collection extends E> coll) {
40 | return UniJ.setFactory().copyOf(coll);
41 | }
42 | //endregion
43 |
44 | //region OF
45 |
46 | /**
47 | * Equivalent of {@link Set#of()}.
48 | */
49 | @ReadOnly
50 | public static Set of() {
51 | return UniJ.setFactory().of();
52 | }
53 |
54 | /**
55 | * Equivalent of {@link Set#of(Object)}.
56 | */
57 | @ReadOnly
58 | public static Set of(E e1) {
59 | return UniJ.setFactory().of(e1);
60 | }
61 |
62 | /**
63 | * Equivalent of {@link Set#of(Object, Object)}.
64 | */
65 | @ReadOnly
66 | public static Set of(E e1, E e2) {
67 | return UniJ.setFactory().of(e1, e2);
68 | }
69 |
70 | /**
71 | * Equivalent of {@link Set#of(Object, Object, Object)}.
72 | */
73 | @ReadOnly
74 | public static Set of(E e1, E e2, E e3) {
75 | return UniJ.setFactory().of(e1, e2, e3);
76 | }
77 |
78 | /**
79 | * Equivalent of {@link Set#of(Object, Object, Object, Object)}.
80 | */
81 | @ReadOnly
82 | public static Set of(E e1, E e2, E e3, E e4) {
83 | return UniJ.setFactory().of(e1, e2, e3, e4);
84 | }
85 |
86 | /**
87 | * Equivalent of {@link Set#of(Object, Object, Object, Object, Object)}.
88 | */
89 | @ReadOnly
90 | public static Set of(E e1, E e2, E e3, E e4, E e5) {
91 | return UniJ.setFactory().of(e1, e2, e3, e4, e5);
92 | }
93 |
94 | /**
95 | * Equivalent of {@link Set#of(Object, Object, Object, Object, Object, Object)}.
96 | */
97 | @ReadOnly
98 | public static Set of(E e1, E e2, E e3, E e4, E e5, E e6) {
99 | return UniJ.setFactory().of(e1, e2, e3, e4, e5, e6);
100 | }
101 |
102 | /**
103 | * Equivalent of {@link Set#of(Object, Object, Object, Object, Object, Object, Object)}.
104 | */
105 | @ReadOnly
106 | public static Set of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
107 | return UniJ.setFactory().of(e1, e2, e3, e4, e5, e6, e7);
108 | }
109 |
110 | /**
111 | * Equivalent of {@link Set#of(Object, Object, Object, Object, Object, Object, Object, Object)}.
112 | */
113 | @ReadOnly
114 | public static Set of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
115 | return UniJ.setFactory().of(e1, e2, e3, e4, e5, e6, e7, e8);
116 | }
117 |
118 | /**
119 | * Equivalent of {@link Set#of(Object, Object, Object, Object, Object, Object, Object, Object, Object)}.
120 | */
121 | @ReadOnly
122 | public static Set of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
123 | return UniJ.setFactory().of(e1, e2, e3, e4, e5, e6, e7, e8, e9);
124 | }
125 |
126 | /**
127 | * Equivalent of {@link Set#of(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)}.
128 | */
129 | @SuppressWarnings("PMD.ExcessiveParameterList")
130 | @ReadOnly
131 | public static Set of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
132 | return UniJ.setFactory().of(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
133 | }
134 |
135 | /**
136 | * Equivalent of {@link Set#of(Object[])}.
137 | */
138 | @SafeVarargs
139 | @ReadOnly
140 | public static Set of(E... elements) {
141 | return UniJ.setFactory().of(elements);
142 | }
143 | //endregion
144 | }
145 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/src/main/java/pl/tlinkowski/unij/api/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | /**
19 | * UniJ API for the end users.
20 | *
21 | * @author Tomasz Linkowski
22 | */
23 | @NonNullPackage
24 | package pl.tlinkowski.unij.api;
25 |
26 | import pl.tlinkowski.annotation.basic.NonNullPackage;
27 |
--------------------------------------------------------------------------------
/subprojects/api/pl.tlinkowski.unij.api/src/test/groovy/pl/tlinkowski/unij/api/UniCollectorsSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2018-2021 Tomasz Linkowski.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package pl.tlinkowski.unij.api
19 |
20 | import spock.lang.Specification
21 |
22 | import java.util.stream.Collectors
23 | import java.util.stream.Stream
24 |
25 | /**
26 | * @author Tomasz Linkowski
27 | */
28 | class UniCollectorsSpec extends Specification {
29 |
30 | def "toUnmodifiableList()"(List list) {
31 | expect:
32 | list.stream().collect(UniCollectors.toUnmodifiableList()) == list
33 | where:
34 | list | _
35 | [] | _
36 | [1] | _
37 | [1, 2] | _
38 | [1, 2, 3] | _
39 | }
40 |
41 | def "toUnmodifiableSet()"(Set set) {
42 | expect:
43 | set.stream().collect(UniCollectors.toUnmodifiableSet()) == set
44 | where:
45 | set | _
46 | [] | _
47 | [1] | _
48 | [1, 2] | _
49 | [1, 2, 3] | _
50 | }
51 |
52 | //region TO UNMODIFIABLE MAP (excerpt from AbstractUnmodifiableMapFactorySpec)
53 | def "toUnmodifiableMap(keyMapper,valueMapper)"(Map map) {
54 | given:
55 | def entryStream = map.entrySet().stream()
56 | def collector = UniCollectors.toUnmodifiableMap({ it.getKey() }, { it.getValue() })
57 | expect:
58 | entryStream.collect(collector) == map
59 | where:
60 | map | _
61 | [:] | _
62 | ["a": 1] | _
63 | ["a": 1, "b": 2] | _
64 | ["a": 1, "b": 2, "c": 3] | _
65 | }
66 |
67 | def "toUnmodifiableMap(keyMapper,valueMapper,mergeFunction)"(List