All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.swagger.util.AllowableEnumValues Maven / Gradle / Ivy

There is a newer version: 1.5.7
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy