!1 apache-commons-collections package init
Merge pull request !1 from jackie_wu123/master
This commit is contained in:
commit
f06cb4f8a7
165
0001-Port-to-Java-8.patch
Normal file
165
0001-Port-to-Java-8.patch
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
From 066f654cd6a1b9d3bfd54565af1d618dada2deb4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michael Simacek <msimacek@redhat.com>
|
||||||
|
Date: Tue, 17 Nov 2015 01:02:55 +0100
|
||||||
|
Subject: [PATCH] Port to Java 8
|
||||||
|
|
||||||
|
---
|
||||||
|
src/java/org/apache/commons/collections/MultiHashMap.java | 8 ++++----
|
||||||
|
src/java/org/apache/commons/collections/MultiMap.java | 4 ++--
|
||||||
|
src/java/org/apache/commons/collections/map/MultiKeyMap.java | 8 +++++---
|
||||||
|
src/java/org/apache/commons/collections/map/MultiValueMap.java | 8 ++++----
|
||||||
|
src/test/org/apache/commons/collections/TestMultiHashMap.java | 10 +++++-----
|
||||||
|
.../org/apache/commons/collections/map/TestMultiKeyMap.java | 4 ++--
|
||||||
|
6 files changed, 22 insertions(+), 20 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/java/org/apache/commons/collections/MultiHashMap.java b/src/java/org/apache/commons/collections/MultiHashMap.java
|
||||||
|
index 7fec9af..bcb4a11 100644
|
||||||
|
--- a/src/java/org/apache/commons/collections/MultiHashMap.java
|
||||||
|
+++ b/src/java/org/apache/commons/collections/MultiHashMap.java
|
||||||
|
@@ -331,21 +331,21 @@ public class MultiHashMap extends HashMap implements MultiMap {
|
||||||
|
* @param item the value to remove
|
||||||
|
* @return the value removed (which was passed in), null if nothing removed
|
||||||
|
*/
|
||||||
|
- public Object remove(Object key, Object item) {
|
||||||
|
+ public boolean remove(Object key, Object item) {
|
||||||
|
Collection valuesForKey = getCollection(key);
|
||||||
|
if (valuesForKey == null) {
|
||||||
|
- return null;
|
||||||
|
+ return false;
|
||||||
|
}
|
||||||
|
boolean removed = valuesForKey.remove(item);
|
||||||
|
if (removed == false) {
|
||||||
|
- return null;
|
||||||
|
+ return false;
|
||||||
|
}
|
||||||
|
// remove the list if it is now empty
|
||||||
|
// (saves space, and allows equals to work)
|
||||||
|
if (valuesForKey.isEmpty()){
|
||||||
|
remove(key);
|
||||||
|
}
|
||||||
|
- return item;
|
||||||
|
+ return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
diff --git a/src/java/org/apache/commons/collections/MultiMap.java b/src/java/org/apache/commons/collections/MultiMap.java
|
||||||
|
index be9455b..4d9cc7d 100644
|
||||||
|
--- a/src/java/org/apache/commons/collections/MultiMap.java
|
||||||
|
+++ b/src/java/org/apache/commons/collections/MultiMap.java
|
||||||
|
@@ -66,7 +66,7 @@ public interface MultiMap extends Map {
|
||||||
|
* @throws ClassCastException if the key or value is of an invalid type
|
||||||
|
* @throws NullPointerException if the key or value is null and null is invalid
|
||||||
|
*/
|
||||||
|
- public Object remove(Object key, Object item);
|
||||||
|
+ public boolean remove(Object key, Object item);
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
@@ -144,7 +144,7 @@ public interface MultiMap extends Map {
|
||||||
|
* @throws ClassCastException if the key is of an invalid type
|
||||||
|
* @throws NullPointerException if the key is null and null keys are invalid
|
||||||
|
*/
|
||||||
|
- Object remove(Object key);
|
||||||
|
+ //boolean remove(Object key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a collection containing all the values in the map.
|
||||||
|
diff --git a/src/java/org/apache/commons/collections/map/MultiKeyMap.java b/src/java/org/apache/commons/collections/map/MultiKeyMap.java
|
||||||
|
index 9e3e02d..969d11e 100644
|
||||||
|
--- a/src/java/org/apache/commons/collections/map/MultiKeyMap.java
|
||||||
|
+++ b/src/java/org/apache/commons/collections/map/MultiKeyMap.java
|
||||||
|
@@ -197,7 +197,7 @@ public class MultiKeyMap
|
||||||
|
* @param key2 the second key
|
||||||
|
* @return the value mapped to the removed key, null if key not in map
|
||||||
|
*/
|
||||||
|
- public Object remove(Object key1, Object key2) {
|
||||||
|
+ public boolean remove(Object key1, Object key2) {
|
||||||
|
int hashCode = hash(key1, key2);
|
||||||
|
int index = map.hashIndex(hashCode, map.data.length);
|
||||||
|
AbstractHashedMap.HashEntry entry = map.data[index];
|
||||||
|
@@ -206,12 +206,14 @@ public class MultiKeyMap
|
||||||
|
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) {
|
||||||
|
Object oldValue = entry.getValue();
|
||||||
|
map.removeMapping(entry, index, previous);
|
||||||
|
- return oldValue;
|
||||||
|
+ //return oldValue;
|
||||||
|
+ return true;
|
||||||
|
}
|
||||||
|
previous = entry;
|
||||||
|
entry = entry.next;
|
||||||
|
}
|
||||||
|
- return null;
|
||||||
|
+ //return null;
|
||||||
|
+ return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
diff --git a/src/java/org/apache/commons/collections/map/MultiValueMap.java b/src/java/org/apache/commons/collections/map/MultiValueMap.java
|
||||||
|
index f44999b..79938dc 100644
|
||||||
|
--- a/src/java/org/apache/commons/collections/map/MultiValueMap.java
|
||||||
|
+++ b/src/java/org/apache/commons/collections/map/MultiValueMap.java
|
||||||
|
@@ -153,19 +153,19 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
||||||
|
* @param value the value to remove
|
||||||
|
* @return the value removed (which was passed in), null if nothing removed
|
||||||
|
*/
|
||||||
|
- public Object remove(Object key, Object value) {
|
||||||
|
+ public boolean remove(Object key, Object value) {
|
||||||
|
Collection valuesForKey = getCollection(key);
|
||||||
|
if (valuesForKey == null) {
|
||||||
|
- return null;
|
||||||
|
+ return false;
|
||||||
|
}
|
||||||
|
boolean removed = valuesForKey.remove(value);
|
||||||
|
if (removed == false) {
|
||||||
|
- return null;
|
||||||
|
+ return false;
|
||||||
|
}
|
||||||
|
if (valuesForKey.isEmpty()) {
|
||||||
|
remove(key);
|
||||||
|
}
|
||||||
|
- return value;
|
||||||
|
+ return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
diff --git a/src/test/org/apache/commons/collections/TestMultiHashMap.java b/src/test/org/apache/commons/collections/TestMultiHashMap.java
|
||||||
|
index eca833a..f47c6f9 100644
|
||||||
|
--- a/src/test/org/apache/commons/collections/TestMultiHashMap.java
|
||||||
|
+++ b/src/test/org/apache/commons/collections/TestMultiHashMap.java
|
||||||
|
@@ -464,11 +464,11 @@ public class TestMultiHashMap extends AbstractTestMap {
|
||||||
|
map.put("A", "AA");
|
||||||
|
map.put("A", "AB");
|
||||||
|
map.put("A", "AC");
|
||||||
|
- assertEquals(null, map.remove("C", "CA"));
|
||||||
|
- assertEquals(null, map.remove("A", "AD"));
|
||||||
|
- assertEquals("AC", map.remove("A", "AC"));
|
||||||
|
- assertEquals("AB", map.remove("A", "AB"));
|
||||||
|
- assertEquals("AA", map.remove("A", "AA"));
|
||||||
|
+ assertEquals(false, map.remove("C", "CA"));
|
||||||
|
+ assertEquals(false, map.remove("A", "AD"));
|
||||||
|
+ assertEquals(true, map.remove("A", "AC"));
|
||||||
|
+ assertEquals(true, map.remove("A", "AB"));
|
||||||
|
+ assertEquals(true, map.remove("A", "AA"));
|
||||||
|
assertEquals(new MultiHashMap(), map);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java b/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
|
||||||
|
index b1ee3d0..66fcade 100644
|
||||||
|
--- a/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
|
||||||
|
+++ b/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
|
||||||
|
@@ -315,10 +315,10 @@ public class TestMultiKeyMap extends AbstractTestIterableMap {
|
||||||
|
switch (key.size()) {
|
||||||
|
case 2:
|
||||||
|
assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1)));
|
||||||
|
- assertEquals(value, multimap.remove(key.getKey(0), key.getKey(1)));
|
||||||
|
+ assertEquals(true, multimap.remove(key.getKey(0), key.getKey(1)));
|
||||||
|
assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1)));
|
||||||
|
assertEquals(size - 1, multimap.size());
|
||||||
|
- assertEquals(null, multimap.remove(key.getKey(0), key.getKey(1)));
|
||||||
|
+ assertEquals(false, multimap.remove(key.getKey(0), key.getKey(1)));
|
||||||
|
assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1)));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
--
|
||||||
|
2.5.0
|
||||||
|
|
||||||
86
apache-commons-collections.spec
Normal file
86
apache-commons-collections.spec
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
%global base_name collections
|
||||||
|
%global short_name commons-%{base_name}
|
||||||
|
|
||||||
|
Name: apache-%{short_name}
|
||||||
|
Version: 3.2.2
|
||||||
|
Release: 11
|
||||||
|
Summary: A series of new interfaces,implementations and utilities provided for Java Collections
|
||||||
|
License: ASL 2.0
|
||||||
|
URL: http://commons.apache.org/%{base_name}/
|
||||||
|
Source0: http://www.apache.org/dist/commons/%{base_name}/source/%{short_name}-%{version}-src.tar.gz
|
||||||
|
|
||||||
|
Patch0001: 0001-Port-to-Java-8.patch
|
||||||
|
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
BuildRequires: ant maven-local mvn(org.apache.commons:commons-parent:pom:)
|
||||||
|
BuildRequires: mvn(org.apache.maven.plugins:maven-antrun-plugin)
|
||||||
|
|
||||||
|
%description
|
||||||
|
The Java Collections Framework was a major addition in JDK 1.2. It added many powerful
|
||||||
|
data structures that accelerate development of most significant Java applications.
|
||||||
|
Since that time it has become the recognised standard for collection handling in Java.
|
||||||
|
Commons-Collections seek to build upon the JDK classes by providing new interfaces,
|
||||||
|
implementations and utilities. There are many features, including:
|
||||||
|
- Bag interface for collections that have a number of copies of each object
|
||||||
|
- BidiMap interface for maps that can be looked up from value to key as well and key to value
|
||||||
|
- MapIterator interface to provide simple and quick iteration over maps
|
||||||
|
- Transforming decorators that alter each object as it is added to the collection
|
||||||
|
- Composite collections that make multiple collections look like one
|
||||||
|
- Ordered maps and sets that retain the order elements are added in, including an LRU based map
|
||||||
|
- Reference map that allows keys and/or values to be garbage collected under close control
|
||||||
|
- Many comparator implementations
|
||||||
|
- Many iterator implementations
|
||||||
|
- Adapter classes from array and enumerations to collections
|
||||||
|
- Utilities to test or create typical set-theory properties of collections such as union,
|
||||||
|
intersection, and closure
|
||||||
|
|
||||||
|
%package devel
|
||||||
|
Summary: Libraries and test files for developing applications that use %{name}
|
||||||
|
Requires: %{name} = %{version}-%{release}
|
||||||
|
Provides: %{name}-testframework = %{version}-%{release}
|
||||||
|
Obsoletes: %{name}-testframework < %{version}-%{release}
|
||||||
|
|
||||||
|
%description devel
|
||||||
|
Libraries and test files for developing applications that use %{name}.
|
||||||
|
|
||||||
|
%package help
|
||||||
|
Summary: Help documents for %{name} package
|
||||||
|
Provides: %{name}-testframework-javadoc = %{version}-%{release} %{name}-javadoc = %{version}-%{release}
|
||||||
|
Obsoletes: %{name}-testframework-javadoc < %{version}-%{release} %{name}-javadoc < %{version}-%{release}
|
||||||
|
|
||||||
|
%description help
|
||||||
|
Help documents for %{name} package.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%autosetup -n %{short_name}-%{version}-src -p1
|
||||||
|
|
||||||
|
find . -name "*.jar" -exec rm -f {} \;
|
||||||
|
find . -name "*.class" -exec rm -f {} \;
|
||||||
|
|
||||||
|
sed -i 's/\r//' LICENSE.txt PROPOSAL.html README.txt NOTICE.txt
|
||||||
|
|
||||||
|
%mvn_package :%{short_name}-testframework testframework
|
||||||
|
%mvn_file ':%{short_name}{,-testframework}' %{name}@1 %{short_name}@1
|
||||||
|
|
||||||
|
%build
|
||||||
|
%mvn_build -- -DskipTests
|
||||||
|
|
||||||
|
ant tf.javadoc -Dtf.build.docs=target/site/apidocs/
|
||||||
|
|
||||||
|
%mvn_artifact %{short_name}:%{short_name}-testframework:%{version} target/%{short_name}-testframework-%{version}.jar
|
||||||
|
|
||||||
|
%install
|
||||||
|
%mvn_install
|
||||||
|
|
||||||
|
%files -f .mfiles
|
||||||
|
%license LICENSE.txt
|
||||||
|
|
||||||
|
%files devel -f .mfiles-testframework
|
||||||
|
|
||||||
|
%files help -f .mfiles-javadoc
|
||||||
|
%doc PROPOSAL.html README.txt NOTICE.txt
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Wed Dec 4 2019 wutao <wutao61@huawei.com> - 3.2.2-11
|
||||||
|
- Package init
|
||||||
BIN
commons-collections-3.2.2-src.tar.gz
Normal file
BIN
commons-collections-3.2.2-src.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user