Changed license to LGPLv3.
[javainspect.git] / src / main / java / eu / svjatoslav / inspector / java / methods / EnumerationBuffer.java
1 /*
2  * JavaInspect - Utility to visualize java software
3  * Copyright (C) 2013-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 3 of the GNU Lesser General Public License
7  * or later as published by the Free Software Foundation.
8  */
9
10 package eu.svjatoslav.inspector.java.methods;
11
12 public class EnumerationBuffer {
13
14         private final String enumerationDelimiter;
15
16         private final StringBuffer buffer = new StringBuffer();
17
18         public int enumeratedEntitiesCount = 0;
19
20         public EnumerationBuffer() {
21                 this(", ");
22         }
23
24         public EnumerationBuffer(final String enumerationDelimiter) {
25                 this.enumerationDelimiter = enumerationDelimiter;
26         }
27
28         public void append(final String value) {
29                 buffer.append(value);
30         }
31
32         public void appendEnumeration(final String value) {
33                 if (enumeratedEntitiesCount > 0)
34                         buffer.append(enumerationDelimiter);
35
36                 buffer.append(value);
37                 enumeratedEntitiesCount++;
38         }
39
40         public void resetEnumeration() {
41                 enumeratedEntitiesCount = 0;
42         }
43
44         @Override
45         public String toString() {
46                 return buffer.toString();
47         }
48
49 }