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

com.xlrit.gears.base.util.DisplayedHelper Maven / Gradle / Ivy

There is a newer version: 1.17.5
Show newest version
package com.xlrit.gears.base.util;

public class DisplayedHelper {
	private final StringBuilder sb;
	private boolean excludeNull = false;

	public DisplayedHelper() {
		this.sb = new StringBuilder();
	}

	public DisplayedHelper excludeNulls() {
		excludeNull = true;
		return this;
	}

	public DisplayedHelper includeNulls() {
		excludeNull = false;
		return this;
	}

	public DisplayedHelper add(String name, Object value) {
        if (!excludeNull || value != null) {
            if (!sb.isEmpty()) sb.append(", ");
            sb.append(name).append(": ").append(value);
        }
        return this;
	}

	@Override
	public String toString() {
		return sb.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy