Add Add ConcurrentReferenceHashMap
This commit is contained in:
parent
6d188523fb
commit
0fa7d7323f
|
@ -3,3 +3,7 @@ Copyright 2001-2024 The Apache Software Foundation
|
|||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (https://www.apache.org/).
|
||||
|
||||
The Java source file src/main/java/org/apache/commons/collections4/map/ConcurrentReferenceHashMap.java
|
||||
is from https://github.com/hazelcast/hazelcast and the following notice applies:
|
||||
Copyright (c) 2008-2020, Hazelcast, Inc. All Rights Reserved.
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add TreeBag.TreeBag(Iterable).</action>
|
||||
<action type="add" issue="COLLECTIONS-858" dev="ggregory" due-to="Alexey Pelykh, Alex Herbert, Gary Gregory">Add CartesianProductIterator #509.</action>
|
||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add missing methods in AbstractMapTests.</action>
|
||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add ConcurrentReferenceHashMap.</action>
|
||||
<!-- UPDATE -->
|
||||
<action type="update" issue="COLLECTIONS-857" dev="ggregory" due-to="Claude Warren">Update bloom filter documentation #508.</action>
|
||||
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump commons-codec:commons-codec from 1.17.0 to 1.17.1 #514.</action>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.apache.commons.collections4.map.ConcurrentReferenceHashMap.Option;
|
||||
|
||||
/**
|
||||
* Tests {@link ConcurrentReferenceHashMap}.
|
||||
*
|
||||
* @param <K> the key type.
|
||||
* @param <V> the value type.
|
||||
*/
|
||||
public abstract class AbstractConcurrentReferenceHashMapTest<K, V> extends AbstractMapTest<K, V> {
|
||||
|
||||
protected static final EnumSet<Option> IDENTITY_COMPARISONS = EnumSet.of(Option.IDENTITY_COMPARISONS);
|
||||
|
||||
public AbstractConcurrentReferenceHashMapTest() {
|
||||
super(AbstractConcurrentReferenceHashMapTest.class.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowNullKey() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowNullValueGet() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowNullValuePut() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTestSerialization() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* A sanity test for the test framework.
|
||||
*
|
||||
* @param <K> the key type.
|
||||
* @param <V> the value type.
|
||||
*/
|
||||
public class ConcurrentHashMapSanityTest<K, V> extends AbstractMapTest<K, V> {
|
||||
|
||||
public ConcurrentHashMapSanityTest() {
|
||||
super(ConcurrentHashMapSanityTest.class.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowNullKey() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowNullValueGet() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowNullValuePut() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't test, just a sanity check for the test framework.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTestSerialization() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
return new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapDefaultsTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// The default behavior
|
||||
return ConcurrentReferenceHashMap.<K, V>builder().get();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKSoftVSoftIdCTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.softKeys()
|
||||
.softValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKSoftVSoftTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.softKeys()
|
||||
.softValues()
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKSoftVStrongIdCTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.softKeys()
|
||||
.strongValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKSoftVStrongTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.softKeys()
|
||||
.strongValues()
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKSoftVWeakIdCTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.softKeys()
|
||||
.weakValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKSoftVWeakTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.softKeys()
|
||||
.weakValues()
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKStrongVSoftIdCTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.strongKeys()
|
||||
.softValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKStrongVSoftTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.strongKeys()
|
||||
.softValues()
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKStrongVStrongIdCTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.strongKeys()
|
||||
.strongValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKStrongVStrongTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.strongKeys()
|
||||
.strongValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKStrongVWeakIdCTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.strongKeys()
|
||||
.weakValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKStrongVWeakTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.strongKeys()
|
||||
.weakValues()
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKWeakVSoftIdCTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.weakKeys()
|
||||
.softValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKWeakVSoftTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.weakKeys()
|
||||
.softValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKWeakVStrongIdCTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.weakKeys()
|
||||
.strongValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKWeakVStrongTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.weakKeys()
|
||||
.strongValues()
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKWeakVWeakIdCTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.weakKeys()
|
||||
.weakValues()
|
||||
.setOptions(IDENTITY_COMPARISONS)
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConcurrentReferenceHashMapKWeakVWeakTest<K, V> extends AbstractConcurrentReferenceHashMapTest<K, V> {
|
||||
|
||||
@Override
|
||||
public Map<K, V> makeObject() {
|
||||
// @formatter:off
|
||||
return ConcurrentReferenceHashMap.<K, V>builder()
|
||||
.weakKeys()
|
||||
.weakValues()
|
||||
.get();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.collections4.map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections4.map.ConcurrentReferenceHashMap.Option;
|
||||
import org.apache.commons.collections4.map.ConcurrentReferenceHashMap.ReferenceType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests {@link ConcurrentReferenceHashMap}.
|
||||
*/
|
||||
public class ConcurrentReferenceHashMapTest {
|
||||
|
||||
@Test
|
||||
public void testBuilderAll() {
|
||||
final Map<Integer, String> map0 = new HashMap<>();
|
||||
map0.put(1, "1");
|
||||
// @formatter:off
|
||||
final Map<Integer, String> map = ConcurrentReferenceHashMap.<Integer, String>builder()
|
||||
.setConcurrencyLevel(4)
|
||||
.setInitialCapacity(32)
|
||||
.setKeyReferenceType(ReferenceType.SOFT)
|
||||
.setLoadFactor(0.74f)
|
||||
.setOptions(EnumSet.of(Option.IDENTITY_COMPARISONS))
|
||||
.setSourceMap(map0)
|
||||
.get();
|
||||
// @formatter:on
|
||||
map0.put(2, "2");
|
||||
assertTrue(map.containsKey(1));
|
||||
assertFalse(map.containsKey(2));
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue