pl.chilldev.web.core.util.PhrasesList.java Source code

Java tutorial

Introduction

Here is the source code for pl.chilldev.web.core.util.PhrasesList.java

Source

/**
 * This file is part of the ChillDev-Web.
 *
 * @license http://mit-license.org/ The MIT license
 * @copyright 2014  by Rafa Wrzeszcz - Wrzasq.pl.
 */

package pl.chilldev.web.core.util;

import java.util.ArrayList;

import org.apache.commons.lang3.StringUtils;

/**
 * Phrases container.
 *
 * @version 0.0.1
 * @since 0.0.1
 */
public class PhrasesList extends ArrayList<String> {
    /**
     * Default separator.
     */
    public static final String SEPARATOR_DEFAULT = ",";

    /**
     * Separator for concatenation of elements.
     */
    protected String separator;

    /**
     * Initializes container.
     *
     * @param separator Seperator for generation of string representation.
     * @since 0.0.1
     */
    public PhrasesList(String separator) {
        super();

        this.separator = separator;
    }

    /**
     * Initializes container with default separator.
     *
     * @since 0.0.1
     */
    public PhrasesList() {
        this(PhrasesList.SEPARATOR_DEFAULT);
    }

    /**
     * Changes concatenation separator.
     *
     * @param separator New separator.
     * @since 0.0.1
     */
    public void setSeparator(String separator) {
        this.separator = separator;
    }

    /**
     * Generates concatenated string.
     *
     * @return String representaiton.
     * @since 0.0.1
     */
    public String toString() {
        return StringUtils.join(this.toArray(), this.separator);
    }
}