Created
March 6, 2015 18:38
-
-
Save nherbaut/0951a2d3de18a2e20599 to your computer and use it in GitHub Desktop.
type safe list filtering
This file contains hidden or 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
| @SuppressWarnings("unchecked") | |
| public <T extends Property> Collection<T> getList(final Class<T> t){ | |
| final Properties props = new Properties(); | |
| props.getProperty().add(new Property()); | |
| props.getProperty().add(new SmtpProperty()); | |
| return (Collection<T>) Collections2.filter(props.getProperty(), new Predicate<Property>() { | |
| @Override | |
| public boolean apply(Property input) { | |
| return t.isInstance(input); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment