Skip to main content
fix links to javadocs
Source Link
Grzegorz Rożniecki
  • 28.1k
  • 11
  • 95
  • 116

A bit "prettier" syntax with FluentIterableFluentIterable (since Guava 12):

ImmutableList<String> resourceIds = FluentIterable.from(matchingComputers) .transform(getResourceId) .filter(Predicates.notNull()) .toList(); static final Function<Computer, String> getResourceId = new Function<Computer, String>() { @Override public String apply(Computer computer) { return computer.getResourceId(); } }; 

Note that the returned list is an ImmutableList. However, you can use copyInto() method to pour the elements into an arbitrary collection.

A bit "prettier" syntax with FluentIterable (since Guava 12):

ImmutableList<String> resourceIds = FluentIterable.from(matchingComputers) .transform(getResourceId) .filter(Predicates.notNull()) .toList(); static final Function<Computer, String> getResourceId = new Function<Computer, String>() { @Override public String apply(Computer computer) { return computer.getResourceId(); } }; 

Note that the returned list is an ImmutableList. However, you can use copyInto() method to pour the elements into an arbitrary collection.

A bit "prettier" syntax with FluentIterable (since Guava 12):

ImmutableList<String> resourceIds = FluentIterable.from(matchingComputers) .transform(getResourceId) .filter(Predicates.notNull()) .toList(); static final Function<Computer, String> getResourceId = new Function<Computer, String>() { @Override public String apply(Computer computer) { return computer.getResourceId(); } }; 

Note that the returned list is an ImmutableList. However, you can use copyInto() method to pour the elements into an arbitrary collection.

added 101 characters in body
Source Link
Natix
  • 14.3k
  • 7
  • 57
  • 69

A bit "prettier" syntax with FluentIterable (since Guava 12):

List<String>ImmutableList<String> resourceIds = FluentIterable.from(matchingComputers) .transform(getResourceId) .filter(Predicates.notNull()) .toList(); static final Function<Computer, String> getResourceId = new Function<Computer, String>() { @Override public String apply(Computer computer) { return computer.getResourceId(); } }; 

Note that the returned list is an ImmutableList. However, you can use copyInto() method to pour the elements into an arbitrary collection.

A bit "prettier" syntax with FluentIterable (since Guava 12):

List<String> resourceIds = FluentIterable.from(matchingComputers) .transform(getResourceId) .filter(Predicates.notNull()) .toList(); static final Function<Computer, String> getResourceId = new Function<Computer, String>() { @Override public String apply(Computer computer) { return computer.getResourceId(); } }; 

Note that the returned list is an ImmutableList.

A bit "prettier" syntax with FluentIterable (since Guava 12):

ImmutableList<String> resourceIds = FluentIterable.from(matchingComputers) .transform(getResourceId) .filter(Predicates.notNull()) .toList(); static final Function<Computer, String> getResourceId = new Function<Computer, String>() { @Override public String apply(Computer computer) { return computer.getResourceId(); } }; 

Note that the returned list is an ImmutableList. However, you can use copyInto() method to pour the elements into an arbitrary collection.

added 52 characters in body
Source Link
Natix
  • 14.3k
  • 7
  • 57
  • 69

A bit "prettier" syntax with FluentIterable (since Guava 12):

List<String> resourceIds = FluentIterable.from(matchingComputers) .transform(getResourceId) .filter(Predicates.notNull()) .toList(); static final Function<Computer, String> getResourceId = new Function<Computer, String>() { @Override public String apply(Computer computer) { return computer.getResourceId(); } }; 

Note that the returned list is an ImmutableList.

A bit "prettier" syntax with FluentIterable (since Guava 12):

List<String> resourceIds = FluentIterable.from(matchingComputers) .transform(getResourceId) .filter(Predicates.notNull()) .toList(); static final Function<Computer, String> getResourceId = new Function<Computer, String>() { @Override public String apply(Computer computer) { return computer.getResourceId(); } }; 

A bit "prettier" syntax with FluentIterable (since Guava 12):

List<String> resourceIds = FluentIterable.from(matchingComputers) .transform(getResourceId) .filter(Predicates.notNull()) .toList(); static final Function<Computer, String> getResourceId = new Function<Computer, String>() { @Override public String apply(Computer computer) { return computer.getResourceId(); } }; 

Note that the returned list is an ImmutableList.

added 23 characters in body
Source Link
Natix
  • 14.3k
  • 7
  • 57
  • 69
Loading
Source Link
Natix
  • 14.3k
  • 7
  • 57
  • 69
Loading