All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mvel2.util.Make Maven / Gradle / Ivy

Go to download

TBEL is a powerful expression language for ThingsBoard platform user-defined functions. Original implementation is based on MVEL.

There is a newer version: 1.2.4
Show newest version
package org.mvel2.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

public class Make {
  public static class Map {
    public static  Map $() {
      return start();
    }

    public static  Map start() {
      return new Map(new HashMap());
    }

    public static  Map start(Class mapImpl) {
      try {
        return new Map(mapImpl.newInstance());
      }
      catch (Throwable t) {
        throw new RuntimeException("error creating instance", t);
      }
    }

    private java.util.Map mapInstance;

    private Map(java.util.Map mapInstance) {
      this.mapInstance = mapInstance;
    }

    public Map _put(K key, V value) {
      mapInstance.put(key, value);
      return this;
    }

    public java.util.Map _finish() {
      return finish();
    }

    public java.util.Map finish() {
      return mapInstance;
    }
  }

  public static class String {
    public static String $() {
      return start();
    }

    public static String start() {
      return new String(new StringBuilder());
    }

    public java.lang.String _finish() {
      return finish();
    }

    public java.lang.String finish() {
      return stringAppender.toString();
    }

    private StringBuilder stringAppender;

    String(StringBuilder stringAppender) {
      this.stringAppender = stringAppender;
    }

    public String _append( char c) {
      stringAppender.append(c);
      return this;
    }

    public String _append( CharSequence cs) {
      stringAppender.append(cs);
      return this;
    }

    public String _append( String s) {
      stringAppender.append(s);
      return this;
    }
  }

  public static class List {
    public static  List $() {
      return start();
    }

    public static  List start() {
      return new List(new ArrayList());
    }

    public static  List start(Class listImpl) {
      try {
        return new List(listImpl.newInstance());
      }
      catch (Throwable t) {
        throw new RuntimeException("error creating instance", t);
      }
    }

    private java.util.List listInstance;

    List(java.util.List listInstance) {
      this.listInstance = listInstance;
    }

    public List _add(V value) {
      listInstance.add(value);
      return this;
    }

    public java.util.List _finish() {
      return finish();
    }

    public java.util.List finish() {
      return listInstance;
    }
  }

  public static class Set {
    public static  Set $() {
      return start();
    }

    public static  Set start() {
      return new Set(new HashSet());
    }

    public static  Set start(Class listImpl) {
      try {
        return new Set(listImpl.newInstance());
      }
      catch (Throwable t) {
        throw new RuntimeException("error creating instance", t);
      }
    }

    private java.util.Set listInstance;

    Set(java.util.Set listInstance) {
      this.listInstance = listInstance;
    }

    public Set _add(V value) {
      listInstance.add(value);
      return this;
    }

    public java.util.Set _finish() {
      return finish();
    }

    public java.util.Set finish() {
      return listInstance;
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy