// Create an array to store local label objects.
Label[] labels = new Label[5];
for (int i = 0; i < 5; i++) {
Label label = new Label();
label.setName("Label #" + i);
label.setTypes(new LabelType[] {LabelType.COMPETITIVE_EXCLUSION});
labels[i] = label;
}
// Create the labels on the server.
labels = labelService.createLabels(labels);
if (labels != null) {
for (Label label : labels) {
List<String> labelTypes = new ArrayList<String>();
for (LabelType labelType : label.getTypes()) {
labelTypes.add(labelType.toString());
}
System.out.println("A label with ID \"" + label.getId()
+ "\", name \"" + label.getName()
+ "\", and types {" + StringUtils.join(labelTypes, ",") + "} was created.");
}
} else {
System.out.println("No labels created.");
}