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

xapi.collect.impl.StringStack Maven / Gradle / Ivy

Go to download

Everything needed to run a comprehensive dev environment. Just type X_ and pick a service from autocomplete; new dev modules will be added as they are built. The only dev service not included in the uber jar is xapi-dev-maven, as it includes all runtime dependencies of maven, adding ~4 seconds to build time, and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).

The newest version!
package xapi.collect.impl;

public class StringStack  {
  
  public StringStack next;
  String prefix = "";
  T value;

  public StringStack push(String prefix, T b) {
    StringStack node = new StringStack();
    node.prefix = prefix == null ? "" : prefix;
    node.value = b;
    assert next == null : "Pushing to the same stack twice overwrites old value.";
    // Instead, just do tail = tail.push("", value);
    next = node;
    return node;
  }
  
  
  public T getValue() {
    return value;
  }

  public void setValue(T value) {
    this.value = value;
  }
  
  public void setPrefix(String prefix) {
    this.prefix = prefix;
  }
  
  @Override
  public final String toString() {
    return prefix + 
        (next == null ? toString(value) : toString(value) + next);
  }

  protected String toString(T item) {
    return item == null ? "" : item.toString();
  }
  
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy