com.github.kongchen.swagger.docgen.remote.ListConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swagger-maven-plugin Show documentation
Show all versions of swagger-maven-plugin Show documentation
A maven build plugin which helps you generate API document during build phase
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()));
}
}