org.mvel2.util.Make Maven / Gradle / Ivy
package org.mvel2.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
public class Make {
public static class Map {
private java.util.Map mapInstance;
private Map(java.util.Map mapInstance) {
this.mapInstance = mapInstance;
}
public static Map $() {
return start();
}
public static Map start() {
return new Map(new HashMap());
}
public static Map start(Class extends java.util.Map> mapImpl) {
try {
return new Map(mapImpl.newInstance());
} catch (Throwable t) {
throw new RuntimeException("error creating instance", t);
}
}
public Map _(K key, V value) {
mapInstance.put(key, value);
return this;
}
public java.util.Map _() {
return finish();
}
public java.util.Map finish() {
return mapInstance;
}
}
public static class String {
private StringBuilder stringAppender;
String(StringBuilder stringAppender) {
this.stringAppender = stringAppender;
}
public static String $() {
return start();
}
public static String start() {
return new String(new StringBuilder());
}
public java.lang.String _() {
return finish();
}
public java.lang.String finish() {
return stringAppender.toString();
}
public String _(char c) {
stringAppender.append(c);
return this;
}
public String _(CharSequence cs) {
stringAppender.append(cs);
return this;
}
public String _(String s) {
stringAppender.append(s);
return this;
}
}
public static class List {
private java.util.List listInstance;
List(java.util.List listInstance) {
this.listInstance = listInstance;
}
public static List $() {
return start();
}
public static List start() {
return new List(new ArrayList());
}
public static List start(Class extends java.util.List> listImpl) {
try {
return new List(listImpl.newInstance());
} catch (Throwable t) {
throw new RuntimeException("error creating instance", t);
}
}
public List _(V value) {
listInstance.add(value);
return this;
}
public java.util.List _() {
return finish();
}
public java.util.List finish() {
return listInstance;
}
}
public static class Set {
private java.util.Set listInstance;
Set(java.util.Set listInstance) {
this.listInstance = listInstance;
}
public static Set $() {
return start();
}
public static Set start() {
return new Set(new HashSet());
}
public static Set start(Class extends java.util.Set> listImpl) {
try {
return new Set(listImpl.newInstance());
} catch (Throwable t) {
throw new RuntimeException("error creating instance", t);
}
}
public Set _(V value) {
listInstance.add(value);
return this;
}
public java.util.Set _() {
return finish();
}
public java.util.Set finish() {
return listInstance;
}
}
}