public List<Library> getLibs() { return this.api.uses(); }
@Override public Iterable<TypeDeclaration> findTypes(Api api) { List<TypeDeclaration> foundTypes = new ArrayList<>(); Utils.goThroughLibraries(foundTypes, new HashSet<String>(), api.uses()); return foundTypes; } };
private Map<String, RamlDataType> getAllTypes(Api api) { Map<String, RamlDataType> types = api.types().stream() .collect(Collectors.toMap(this::nameType, this::typeDeclarationToRamlDataType)); api.uses().forEach(lib -> this.getTypesFromLib(types, lib)); return types; }
@Override public Map<String, RamlDataType> getTypes() { Map<String, RamlDataType> types = getAllTypes(api); // When searching for all libraries that other libraries use it's // possible to pull in same library multiple times. // In order to avoid IllegalStateException we'll add basic // mergeFunction. Map<String, RamlDataType> libOfLibTypes = api.uses().stream().flatMap(x -> x.uses().stream()).flatMap(x -> x.types().stream()) .collect(Collectors.toMap(this::nameType, this::typeDeclarationToRamlDataType, (x, y) -> x)); types.putAll(libOfLibTypes); return types; }
@Override public TypeDeclaration fetchType(Api api, final String name) throws GenerationException { return FluentIterable.from(Optional.fromNullable(foundInApi).or(Utils.goThroughLibraries(new ArrayList<TypeDeclaration>(), new HashSet<String>(), api.uses()))) .firstMatch(namedPredicate(name)).or(fail(name)); } };
@Override public TypeDeclaration fetchType(Api api, final String name) throws GenerationException { return FluentIterable.from(Optional.fromNullable(foundInApi).or(FluentIterable.from(api.types()).append(Utils.goThroughLibraries(new ArrayList<TypeDeclaration>(), new HashSet<String>(), api.uses())))) .firstMatch(namedPredicate(name)).or(fail(name)); }
@Override public Iterable<TypeDeclaration> findTypes(Api api) { return FluentIterable.from(api.types()) .append(resourceTypes(api.resources())) .append(Utils.goThroughLibraries(new ArrayList<TypeDeclaration>(), new HashSet<String>(), api.uses())); } };