org.rythmengine.utils.F Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rythm-engine Show documentation
Show all versions of rythm-engine Show documentation
A strong typed high performance Java Template engine with .Net Razor like syntax
/**
* Copyright (C) 2013-2016 The Rythm Engine project
* for LICENSE and other details see:
* https://github.com/rythmengine/rythmengine
*/
package org.rythmengine.utils;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* Utility classes
*/
// Most of the code come from Play!Framework F.java, under Apache License 2.0
public class F {
private F() {
}
public static interface Action0 {
void invoke();
}
public static interface Action {
void invoke(T result);
}
public static abstract class Option implements Iterable {
public abstract boolean isDefined();
public abstract T get();
public static None none() {
return (None) (Object) None;
}
public static Some some(T value) {
return new Some(value);
}
}
public static Some some(A a) {
return new Some(a);
}
public static class None extends Option {
@Override
public boolean isDefined() {
return false;
}
@Override
public T get() {
throw new IllegalStateException("No value");
}
public Iterator iterator() {
return Collections.emptyList().iterator();
}
@Override
public String toString() {
return "None";
}
}
public static final None