Went ahead and did the complicated thing, it's good exercise.
Definitely does not pass the "less code is better code" test. :( git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@827 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -32,6 +32,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterators;
|
import com.google.common.collect.Iterators;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@@ -226,12 +227,19 @@ public class BundledComponentRepository
|
|||||||
// documentation inherited
|
// documentation inherited
|
||||||
public Iterator<Integer> enumerateComponentIds (final ComponentClass compClass)
|
public Iterator<Integer> enumerateComponentIds (final ComponentClass compClass)
|
||||||
{
|
{
|
||||||
return Iterators.filter(_components.keySet().iterator(), new Predicate<Integer>() {
|
Predicate<Map.Entry<Integer,CharacterComponent>> pred =
|
||||||
public boolean apply (Integer input) {
|
new Predicate<Map.Entry<Integer,CharacterComponent>>() {
|
||||||
CharacterComponent comp = _components.get(input);
|
public boolean apply (Map.Entry<Integer,CharacterComponent> entry) {
|
||||||
return comp.componentClass.equals(compClass);
|
return entry.getValue().componentClass.equals(compClass);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
Function<Map.Entry<Integer,CharacterComponent>,Integer> func =
|
||||||
|
new Function<Map.Entry<Integer,CharacterComponent>,Integer>() {
|
||||||
|
public Integer apply (Map.Entry<Integer,CharacterComponent> entry) {
|
||||||
|
return entry.getKey();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return Iterators.transform(Iterators.filter(_components.entrySet().iterator(), pred), func);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user