org.jdesktop.swingx.util.Separator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swingx-all Show documentation
Show all versions of swingx-all Show documentation
Fork of the inactive swingx-all library
package org.jdesktop.swingx.util;
/**
* A simple separator for adding in between each element in a list.
*
*
* for (String s : strings) {
* stringBuilder.append(separator.get().append(s);
* }
*
*
* @param the type of separator
* @author Karl Schaefer
* @author Bruce Chapman (original idea)
*/
public class Separator {
private T next;
private final T separator;
/**
* Constructs a separator with the specified initial value and remaining separator.
*
* @param initial the value to use for the first call
* @param separator the value to use after the first call
*/
public Separator(T initial, T separator) {
this.next = initial;
this.separator = separator;
}
/**
* Returns the current value of the separator.
*
* @return the separator value
*/
public T get() {
T result = next;
next = separator;
return result;
}
}