Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove apache.commons.coll: CollectionUtils.filter, AbstractMapEntry #1287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 deletions mondrian/src/main/java/mondrian/olap/IdBatchResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import org.apache.log4j.Logger;

import java.util.*;

import static org.apache.commons.collections.CollectionUtils.filter;
import java.util.stream.Collectors;

/**
* Used to collect and resolve identifiers in groups of children
Expand Down Expand Up @@ -255,29 +254,12 @@ private List<Member> lookupChildrenByNames(
private List<Id.NameSegment> collectChildrenNameSegments(
final Member parentMember, List<Id> children)
{
filter(
children, new Predicate() {
// remove children we can't support
public boolean evaluate(Object theId)
{
Id id = (Id)theId;
return !Util.matches(parentMember, id.getSegments())
&& supportedIdentifier(id);
}
});
return new ArrayList(
CollectionUtils.collect(
children, new Transformer()
{
// convert the collection to a list of NameSegments
public Object transform(Object theId) {
Id id = (Id)theId;
return getLastSegment(id);
}
}));
return children.stream().filter(id -> !Util.matches(parentMember, id.getSegments()) && supportedIdentifier(id))
//supportedIdentifier(i) checks instanceof NameSegment
.map(id -> (Id.NameSegment)getLastSegment(id)).collect(Collectors.toList());
}

private Id.Segment getLastSegment(Id id) {
private static Id.Segment getLastSegment(Id id) {
int segSize = id.getSegments().size();
return id.getSegments().get(segSize - 1);
}
Expand All @@ -297,7 +279,7 @@ private boolean supportedIdentifier(Id id) {
&& !id.getSegments().get(0).matches("Measures");
}

private boolean supportedMember(Member member) {
private static boolean supportedMember(Member member) {
return !(member == null
|| member.equals(
member.getHierarchy().getNullMember())
Expand Down
5 changes: 2 additions & 3 deletions mondrian/src/main/java/mondrian/olap/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.collections.keyvalue.AbstractMapEntry;
import org.apache.commons.io.IOUtils;
import org.apache.commons.vfs2.FileContent;
import org.apache.commons.vfs2.FileObject;
Expand Down Expand Up @@ -4488,8 +4487,8 @@ public void remove() {
}
@SuppressWarnings("unchecked")
public Entry<K, V> next() {
return new AbstractMapEntry(
list.get(++pt), null) {};
return new AbstractMap.SimpleEntry<K,V>(
list.get(++pt), null);
}
public boolean hasNext() {
return pt < list.size();
Expand Down