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

net.alloyggp.escaperope.rope.ropify.RopeBuilder Maven / Gradle / Ivy

There is a newer version: 0.0.5
Show newest version
package net.alloyggp.escaperope.rope.ropify;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.concurrent.NotThreadSafe;

import net.alloyggp.escaperope.rope.ListRope;
import net.alloyggp.escaperope.rope.Rope;
import net.alloyggp.escaperope.rope.StringRope;

/**
 * RopeBuilders are not thread-safe.
 */
@NotThreadSafe
public class RopeBuilder {
    private final List list = new ArrayList<>();

    private RopeBuilder() {
        //Use a create() method instead
    }

    public static RopeBuilder create() {
        return new RopeBuilder();
    }

    public void add(Rope rope) {
        list.add(rope);
    }

    public  void add(T object, RopeWeaver weaver) {
        list.add(weaver.toRope(object));
    }

    public void add(String string) {
        list.add(StringRope.create(string));
    }

    public List toList() {
        return new ArrayList<>(list);
    }

    public Rope toRope() {
        return ListRope.create(list);
    }

    /**
     * Adds the string representation of the long value.
     */
    public void add(long longValue) {
        add(Long.toString(longValue));
    }

    public void add(boolean b) {
        add(Boolean.toString(b));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy