All Questions
32 questions
5
votes
3
answers
2k
views
Zip two lists into an immutable multimap in Java 8 with Guava?
The for loop looks like
ImmutableListMultiMap.<Key, Value>Builder builder
= ImmutableListMultiMap.<Key, Value>newBuilder();
for (int i = 0; i < Math.min(keys.length(), values....
2
votes
1
answer
356
views
What is the idiomatic way to map a Collection<Foo> onto a MultiMap<A, B>? [duplicate]
What is the idiomatic way to map a Collection<Foo> onto a MultiMap<A, B>? Were
public class Foo {
public A key;
public B val;
}
(This is simplified, of course.)
The way I can ...
1
vote
1
answer
267
views
Can you use a functor/functional programming to group a list in Java 7 (and count its elements per group)?
Can you group List<TypeEnum> types = new ArrayList(Arrays.asList(TypeEnum.A, TypeEnum.B, TypeEnum.A)); into a Map<TypeEnum, Integer> countPerType;, using functors (e.g. Google's Guava, ...
0
votes
1
answer
246
views
Guava function to add items to resultant collection based on applying conditions to each item in list
I am trying to create a set of items by looking through an existing set and adding each one to a resultant list if it meets certain conditions. I was wondering if there was a more efficient way to do ...
0
votes
1
answer
427
views
Can Guava Lists.transform or Iterables.transform take a Converter?
Usually Guava Lists.transform looks like this:
Lists.transform(new ArrayList<String>("1", "2", "3"),
new Function<String, Integer>() {
@Override
Integer apply(String str) {...
0
votes
1
answer
115
views
Correct use of guava Predicate on two types
I'm not sure if I completely understand how guava's Predicate<T> should be use. I have two classes Promotion and Customer, and I want to check which one of the promotions is applicable to a ...
0
votes
2
answers
920
views
Joining a collection based on members of the type
I have a class A and its members b and c.
Now I construct the List<A> with this:
add(new A().setb("abcd").setc("123456"));
add(new A().setb("efgh").setc("789101"));
add(new A().setb("ijkl")....
3
votes
4
answers
992
views
guava - Iterables avoid iterating multiple times
I have a list of objects that contains two string properties.
public class A {
public String a;
public String b;
}
I want to retrieve two Sets one containing property a and one b.
The ...
0
votes
1
answer
86
views
Improving upon the double list iteration using Guava
Basically the question is what is the best way to transform the following code
for (Link updateLink : updateLinks) {
for (Link link : project.getLinks()) {
if(updateLink.equals(link)){
...
0
votes
2
answers
97
views
Get delegate function for arbitrary java method
Is there an easy way to get an arbitrary Function version of a method on a POJO?
For example:
FluentIterable.from(myCollection).uniqueIndex(Functions.for(Item.class).getId)
....
0
votes
1
answer
226
views
Create FluentIterable chain as a function, rather than immediately apply
Is there a way to create a FluentIterable chain of functions, but delay binding to a specific collection?
For example:
Function<Collection<T>, T> chooseBy(Function<T, KEY> ...
1
vote
1
answer
1k
views
Filter a MultiMap<Predicate, value>
Block are some long-lived instances representing types, e.g. A Minecraft BlockType grass, green_wool etc.
I'm trying to find a DataStructure that can efficiently store and test for a given ...
1
vote
1
answer
432
views
Guava Function in interfaces
I am going through an old code base of Java 6 and I see this in one of the interfaces
public static Function<Model, Map<? extends Class<? extends Feature>, Map<String, String>>&...
0
votes
1
answer
171
views
How to test a Google Guava Predicate factory kind of class
I have a class called XxxPredicateFactory which return a single predicate or predicate combination. Something like this:
Public class XxxPredicateFactory {
public Predicate<Abc> create() {...
1
vote
1
answer
192
views
What is best way to iterate embedded loops Iterative or Functional way?
I was looking at some examples using Guava to iterate embedded loops to analyze what fits better in this case.
Our environment uses java 6 and we need to create a excel parser using Apache POI.
...