Skip to content

Commit b486136

Browse files
committed
Simplify email/language builders
1 parent 5a70277 commit b486136

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/main/java/ldbc/snb/datagen/serializer/DynamicPersonSerializer.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Linked Data Benchmark Council (http://www.ldbcouncil.org)
3535
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/
3636
package ldbc.snb.datagen.serializer;
3737

38+
import com.google.common.base.Joiner;
39+
import com.google.common.collect.Iterables;
3840
import ldbc.snb.datagen.dictionary.Dictionaries;
3941
import ldbc.snb.datagen.entities.dynamic.relations.Knows;
4042
import ldbc.snb.datagen.entities.dynamic.person.Person;
@@ -88,26 +90,11 @@ public String getGender(int gender) {
8890
}
8991
}
9092
public String buildLanguages(ArrayList<Integer> languages) {
91-
StringBuilder languagesBuilder = new StringBuilder();
92-
for (int i = 0; i < languages.size()-1; i++) {
93-
languagesBuilder.append(Dictionaries.languages.getLanguageName(languages.get(i))+";");
94-
}
95-
if(languages.size() > 0) {
96-
languagesBuilder.append(Dictionaries.languages.getLanguageName(languages.get(languages.size()-1)));
97-
}
98-
return languagesBuilder.toString();
93+
return Joiner.on(";").join(languages);
9994
}
10095

10196
public String buildEmail(TreeSet<String> emails) {
102-
StringBuilder emailsBuilder = new StringBuilder();
103-
Iterator<String> itString = emails.iterator();
104-
for (int i = 0; i < emails.size()-1; i++) {
105-
emailsBuilder.append(itString.next()+";");
106-
}
107-
if(itString.hasNext()) {
108-
emailsBuilder.append(itString.next());
109-
}
110-
return emailsBuilder.toString();
97+
return Joiner.on(";").join(emails);
11198
}
11299

113100
abstract protected void serialize(final Person p);

0 commit comments

Comments
 (0)