added JPMS support
This commit is contained in:
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@@ -8,7 +8,7 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
sh "./gradlew clean build"
|
sh "./gradlew clean build"
|
||||||
junit testResults: "build/test-results/test/*.xml"
|
junit testResults: "build/test-results/test/*.xml"
|
||||||
javadoc javadocDir: "build/docs/javadoc"
|
javadoc javadocDir: "build/docs/javadoc", keepAll: true
|
||||||
archiveArtifacts artifacts: 'build/libs/*.jar,benchmark/build/libs/*.jar',
|
archiveArtifacts artifacts: 'build/libs/*.jar,benchmark/build/libs/*.jar',
|
||||||
allowEmptyArchive: true,
|
allowEmptyArchive: true,
|
||||||
fingerprint: true,
|
fingerprint: true,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'net.woggioni.plugins.multi-release-jar'
|
id 'net.woggioni.gradle.multi-release-jar'
|
||||||
id 'net.woggioni.gradle.lombok' apply false
|
id 'net.woggioni.gradle.lombok' apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,6 +27,10 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
setProperty('jpms.module.name', 'net.woggioni.jwo')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
pathClassloaderTest
|
pathClassloaderTest
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
gradle.version = 7.1.1
|
gradle.version = 7.2
|
||||||
jwo.version=1.0
|
jwo.version=1.0
|
||||||
junitJupiter.version=5.7.0
|
junitJupiter.version=5.7.0
|
||||||
lombok.version=1.18.16
|
lombok.version=1.18.16
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@@ -8,7 +8,7 @@ pluginManagement {
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id "net.woggioni.gradle.lombok" version "0.1"
|
id "net.woggioni.gradle.lombok" version "0.1"
|
||||||
id "net.woggioni.plugins.multi-release-jar" version "0.1"
|
id "net.woggioni.gradle.multi-release-jar" version "0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
127
src/main/java/net/woggioni/jwo/DelegatingMap.java
Normal file
127
src/main/java/net/woggioni/jwo/DelegatingMap.java
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
package net.woggioni.jwo;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class DelegatingMap<K,V> implements Map<K, V> {
|
||||||
|
private final Supplier<Map<K,V>> mapFactory;
|
||||||
|
private final List<Map<K,V>> delegates;
|
||||||
|
private final Map<K,V> thisMap;
|
||||||
|
|
||||||
|
public DelegatingMap(Supplier<Map<K,V>> mapFactory, List<Map<K,V>> delegates) {
|
||||||
|
this.mapFactory = mapFactory;
|
||||||
|
this.delegates = delegates;
|
||||||
|
thisMap = mapFactory.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
if(!thisMap.isEmpty()) return false;
|
||||||
|
for(Map<K,V> delegate : delegates) {
|
||||||
|
if(!delegate.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsKey(Object key) {
|
||||||
|
if(thisMap.containsKey(key)) return true;
|
||||||
|
for(Map<K,V> delegate : delegates) {
|
||||||
|
if(!delegate.containsKey(key)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsValue(Object value) {
|
||||||
|
if(thisMap.containsValue(value)) return true;
|
||||||
|
for(Map<K,V> delegate : delegates) {
|
||||||
|
if(!delegate.containsValue(value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V get(Object key) {
|
||||||
|
V result = thisMap.get(key);
|
||||||
|
if(result != null) return result;
|
||||||
|
for(Map<K,V> delegate : delegates) {
|
||||||
|
result = delegate.get(key);
|
||||||
|
if(result != null) break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V put(K key, V value) {
|
||||||
|
V result = thisMap.put(key, value);
|
||||||
|
if(result != null) return result;
|
||||||
|
for(Map<K,V> delegate : delegates) {
|
||||||
|
result = delegate.put(key, value);
|
||||||
|
if(result != null) break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V remove(Object key) {
|
||||||
|
V result = thisMap.remove(key);
|
||||||
|
if(result != null) return result;
|
||||||
|
for(Map<K,V> delegate : delegates) {
|
||||||
|
result = delegate.remove(key);
|
||||||
|
if(result != null) break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putAll(Map<? extends K, ? extends V> m) {
|
||||||
|
this.thisMap.putAll(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
thisMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<K> keySet() {
|
||||||
|
return flatten().keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<K, V> flatten() {
|
||||||
|
Map<K, V> result = mapFactory.get();
|
||||||
|
int i = delegates.size();
|
||||||
|
while(i-->0) {
|
||||||
|
Map<K, V> delegate = delegates.get(i);
|
||||||
|
result.putAll(delegate);
|
||||||
|
}
|
||||||
|
result.putAll(thisMap);
|
||||||
|
return Collections.unmodifiableMap(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<V> values() {
|
||||||
|
return flatten().values();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Entry<K, V>> entrySet() {
|
||||||
|
return flatten().entrySet();
|
||||||
|
}
|
||||||
|
}
|
@@ -1,3 +1,4 @@
|
|||||||
module net.woggioni.jwo {
|
module net.woggioni.jwo {
|
||||||
|
requires org.slf4j;
|
||||||
exports net.woggioni.jwo;
|
exports net.woggioni.jwo;
|
||||||
}
|
}
|
Reference in New Issue
Block a user