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

com.github.kongchen.swagger.docgen.remote.ListConverter Maven / Gradle / Ivy

There is a newer version: 3.1.8
Show newest version
package com.github.kongchen.swagger.docgen.remote;

import com.github.kongchen.swagger.docgen.remote.model.CanBeSwaggerModel;
import scala.collection.JavaConversions;

import java.util.ArrayList;
import java.util.List;

/**
 * Convert from java.util.List to scala.collection.immutable.List
 *
* Created by kongchen on 14/10/11.
*/
public class ListConverter, R> {
    private List sources;

    public ListConverter(List sources) {
        this.sources = sources;
    }

    public scala.collection.immutable.List convert() {
        if (sources == null || sources.size() == 0) return null;
        List result = new ArrayList();
        for (T ja : sources) {
            R a = ja.toSwaggerModel();
            if (a != null) {
                result.add(a);
            }
        }
        if (result.size() == 0) {
            return null;
        }
        return scala.collection.immutable.List.fromIterator(JavaConversions.asScalaIterator(result.iterator()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy