Skip to content

Instantly share code, notes, and snippets.

Wojciech Soczyński wsoczynski

Block or report user

Report or block wsoczynski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View resource_loader2.java
class ConcatPath implements Function<String,String> {
private final String subPath;
private ConcatPath(String subPath){
this.subPath = subPath;
}
@Override
public String apply(String basePath){
return FilenameUtils.concat(basePath,subPath);
View resource_loader.java
class HierarchyAwareResourceLoader {
private final List<String> searchPaths;
public HierarchyAwareResourceLoader(List<String> searchPaths){
this.searchPaths = searchPaths;
}
public Optional<File> load(String name){
Optional<File> result = FluentIterable.from(searchPaths).
View fluentIterable7.java
public class PerfTest extends SimpleBenchmark {
private List<Integer> input;
public void setUp() {
List<Integer> input = new LinkedList<Integer>();
for (int i = 0; i < 10000; i++) {
input.add(i);
}
View fluentIterable6.java
public class Sample {
public List<Double> allEvenNumberToSecondPower(List<Integer> input) {
EvenFilter evenFilter = new EvenFilter();
PowerFunction powerFunction = new PowerFunction(2);
ImmutableList<Double> result = FluentIterable.from(input).
filter(evenFilter).
transform(powerFunction).
View fluentIterable5.java
public class Sample {
public List<Double> allEvenNumberToSecondPower(List<Integer> input) {
List<Double> result = new LinkedList<Double>();
for (Integer item : input) {
if (item % 2 == 0) {
result.add(Math.pow(item, 2));
}
View fluentIterable4.java
public class TransformAndConcatTest{
@Test
public void testTransformAndConcat() throws Exception {
//given
List<List<Integer>> input = newLinkedList();
for (int i = 0; i < 10; i++) {
List<Integer> subList = newLinkedList();
for (int j = 0; j < 10; j++) {
subList.add(j);
View fluentIterable3.java
public class GenerateTest {
@Test
public void testGenerate() {
//given
Set<Integer> expected = new LinkedHashSet<Integer>();
for (int i = 1; i < 101; i++) {
expected.add(i);
}
View fluentIterable2.java
public class FluentIterableExample {
public static void main(String... args){
List<Integer> input = generateInput();
EvenFilter evenFilter = new EvenFilter();
PowerFunction powerFunction = new PowerFunction(2);
RangeFilter rangeFilter = new RangeFilter(17, 50);
Optional<Double> result = FluentIterable.from(input).
View fluentIterable1.java
public class FluentIterableExample {
public static void main(String... args){
List<String> input = newArayList();
FluentIterable<String> iterable = FluentIterable.from(input);
//the rest of processing
}
}
View gist:4025133
public class Main {
public Optional<String> someValue = Optional.of("test");
public void main(String... args){
Main m = new Main();
Optional<Int> result = m.someValue.transform(new Function<String,Int>(){
@Override
public String apply(@Nullable String input){
You can’t perform that action at this time.