package net.sourceforge.barbecue.linear.code128;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 覆盖原类，并实现 Serializable，以避免打印期间使用 REPORT_VIRTUALIZER 报错
 *
 * @author sunyj
 * @since 2017/11/13 11:36
 */
public final class CharBuffer implements Serializable {

    private static final long serialVersionUID = 1L;

    private final int size;
    private List<Character> chars;

    public CharBuffer(int var1) {
        this.size = var1;
        this.chars = new ArrayList<>();
    }

    public int size() {
        return this.chars.size();
    }

    public void addChar(char var1) {
        this.chars.add(var1);
    }

    public boolean isFull() {
        return this.chars.size() == this.size;
    }

    public String toString() {
        char[] var1 = new char[this.size];

        for (int var2 = 0; var2 < this.size; ++var2) {
            Character var3 = this.chars.get(var2);
            var1[var2] = var3;
        }

        return new String(var1);
    }

    public void clear() {
        this.chars.clear();
    }
}

