Skip to content

Instantly share code, notes, and snippets.

@vdergachev
Last active June 3, 2017 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdergachev/3dd0908ec0301b1e0357005e669cc726 to your computer and use it in GitHub Desktop.
Save vdergachev/3dd0908ec0301b1e0357005e669cc726 to your computer and use it in GitHub Desktop.
package com.get.some;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Arrays;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {MavenDepPluginBugIT.class})
@Configuration
public class MavenDepPluginBugIT {
@Test
public void test() {
// 1
foo(Arrays.asList("one", null, "three"), StringUtils::isEmpty);
// 2
// if(StringUtils.isEmpty("asd")) {
// System.out.println("empty");
// };
}
interface Operation {
boolean isEmpty(String val);
}
private static void foo(final Iterable<String> it, final Operation operation) {
if (it == null) {
return;
}
it.forEach(string -> {
if (!operation.isEmpty(string)) {
System.out.println(string);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment