Created
July 11, 2010 19:12
-
-
Save zvozin/471752 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> Collection<T> toStringFiltered(List<T> aListOfTs) { | |
return Collections2.filter(aListOfTs, new Predicate<T>() | |
{ | |
public boolean apply(T from) { | |
return from.toString().isEmpty(); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>com.google.collections</groupId> | |
<artifactId>google-collections</artifactId> | |
<version>1.0</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> Collection<String> toString(List<T> aListOfTs) { | |
return Collections2.transform(aListOfTs, new Function<T, String>() | |
{ | |
public String apply(T from) { | |
return from.toString(); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> List<String> toString(List<T> aListOfTs) { | |
List<String> toPrint = new ArrayList<String>(); | |
for (T aT : aListOfTs) { | |
toPrint.add(aT.toString()); | |
} | |
return toPrint; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aListOfTs.map(_.toString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment