Skip to content

Commit

Permalink
After release! (before the 35th May presentation)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalcohen authored and orenafek committed Jun 4, 2017
1 parent 81a9175 commit 355391c
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public void matcher() {
try {
anyNumberOf(statement(0));
} finally {

}
/** end */
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package il.org.spartan.Leonidas.plugin.tippers;

import static spartanizer.SpartanizerUtils.eval;

/**
* @author Michal Cohen
* @since 12/01/17
*/
public class PluginTest35May {

int x;

public static void main(String[] args) {
int x = 7;
Integer z = 4;
Integer y = eval(4).unless(x > 0); // replace with unless nano pattern

// remove braces
if (x > 3)
x++;

// remove braces
while (!(x > 3))
x++;

// remove double negation
if (x > 4)
System.out.print("banana");

// flip condition
if (x > 2)
x++;

// go fluent
class Bloop {
private int s;

Bloop setX(int ¢) {
this.s = ¢;
return this;
}

int get() {
return s;
}
}

// change to x++
x++;

String s = "banana";
// flip equals
"split".equals(s);
}

private static void foo(boolean ¢) {
System.out.print(¢);
}

// should change parameter to cent
int f(int ¢) {
¢ = ¢ + 5;
return ¢ + 1;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package il.org.spartan.Leonidas.plugin.tippers.spartanizer;

import java.util.List;
import java.util.function.Function;

public class SpartanizerUtils {

public static <T> Eval<T> eval(T y) {
return new Eval<T>(y);
}

public static <T> T last(List<T> ts) {
return ts.get(ts.size() - 1);
}

public static <T, R> R nullConditional(T x, Function<T, R> f) {
return x == null ? null : f.apply(x);
}

public static <T> Defaults<T> defaults(T then) {
return new Defaults<T>(then);
}

public static class Eval<T> {
T y;

public Eval(T y) {
this.y = y;
}

public T unless(boolean x) {
return !x ? y : null;
}
}

public static class Defaults<T> {
T then;

public Defaults(T then) {
this.then = then;
}

public T to(T else$) {
return then != null ? then : else$;
}
}
}

0 comments on commit 355391c

Please sign in to comment.