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
@Override | |
public TemplateModel wrap(Object object) throws TemplateModelException { | |
//Joda time stuff omitted | |
if (object instanceof Enum && object.getClass().isAnnotationPresent(BaseName.class)) { | |
return super.wrap(lookUp((Enum<?>) object)); | |
} | |
if (object instanceof MessageParameterObj) { | |
return super.wrap(lookUp((MessageParameterObj) object)); | |
} |
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 class LocalizedBooleanModel implements TemplateScalarModel, TemplateBooleanModel { | |
private final boolean value; | |
private final String yes; | |
private final String no; | |
public LocalizedBooleanModel(boolean value, String yes, String no) { | |
this.value = value; | |
this.yes = yes; | |
this.no = no; |
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 Map<String, Object> getDataModel() { | |
HashMap<String, Object> datamodel = new HashMap<>(); | |
datamodel.put("date", new LocalDate()); | |
datamodel.put("time", new LocalTime()); | |
datamodel.put("month", new YearMonth()); | |
datamodel.put("boolean", true); | |
datamodel.put("greeting", new MessageParameterObj(Messages.HELLO, "Freemarker")); | |
return datamodel; | |
} |
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
${date} | |
${time} | |
${month} | |
${boolean} | |
[#if boolean]${greeting}[/#if] |
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
class AnimalRow extends Snippet { | |
new(Animal animal, int idx) { | |
super("/animal/animal.html", ".per_animal_row") | |
transform | |
=> sub [ | |
select("input.true_name") | |
=> newName("true_name",idx) | |
=> attr("value", animal.trueName) | |
select("input.species") |
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
<form action="/herd_changes" method="post" id="animal_addition_form"> | |
<table> | |
<tr class="per_animal_row"> | |
<td> | |
<input type="text" class="true_name" name="true_name"/> | |
</td> | |
<td> | |
<select class="species" name="species"> | |
<option selected="selected">Bovine</option> |
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
Xtend: | |
@Usually | |
def doStuff() { | |
println("This usually doesn't fail") | |
} | |
generated Java: | |
public void doStuff() { |
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
DECLARE | |
open_count integer; | |
BEGIN | |
-- prevent any further connections | |
EXECUTE IMMEDIATE 'alter user @USERNAME account lock'; | |
--kill all sessions | |
FOR session IN (SELECT sid, serial# | |
FROM v$session | |
WHERE username = '@USERNAME') | |
LOOP |
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
@Memoize def BigInteger fibonacci(int n) { | |
switch n { | |
case 0: 0bi | |
case 1: 1bi | |
default: fibonacci(n - 1) + fibonacci(n - 2) | |
} | |
} |
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
@Memoize | |
public BigInteger fibonacci(final int n) { | |
try { | |
return fibonacci_cache.get(n); | |
} catch(Throwable e) { | |
throw Exceptions.sneakyThrow(e.getCause()); | |
} | |
} | |
private BigInteger fibonacci_init(final int n) { |