io.swagger.util.AllowableEnumValues Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swagger-all Show documentation
Show all versions of swagger-all Show documentation
swagger-all is a rebundled verison of Swagger as one OSGi bundle.
package io.swagger.util;
import io.swagger.models.properties.PropertyBuilder;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
public class AllowableEnumValues implements AllowableValues {
private final List items;
private AllowableEnumValues(List items) {
this.items = items;
}
public static AllowableEnumValues create(String allowableValues) {
final List items = new ArrayList();
for (String value : allowableValues.split(",")) {
final String trimmed = value.trim();
if (!trimmed.equals("")) {
items.add(trimmed);
}
}
return items.isEmpty() ? null : new AllowableEnumValues(items);
}
public List getItems() {
return items;
}
@Override
public Map asPropertyArguments() {
final Map map = new EnumMap(PropertyBuilder.PropertyId.class);
map.put(PropertyBuilder.PropertyId.ENUM, items);
return map;
}
}