Mercurial > repos > shellac > guppy_basecaller
diff env/lib/python3.7/site-packages/schema_salad/java/main_utils/LoadingOptionsBuilder.java @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author | shellac |
---|---|
date | Sat, 02 May 2020 07:14:21 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/env/lib/python3.7/site-packages/schema_salad/java/main_utils/LoadingOptionsBuilder.java Sat May 02 07:14:21 2020 -0400 @@ -0,0 +1,62 @@ +package ${package}.utils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public class LoadingOptionsBuilder { + private Optional<Fetcher> fetcher = Optional.empty(); + private Optional<String> fileUri = Optional.empty(); + private Optional<Map<String, String>> namespaces = Optional.empty(); + private Optional<List<String>> schemas = Optional.empty(); + private Optional<LoadingOptions> copyFrom = Optional.empty(); + + public LoadingOptionsBuilder() {} + + public LoadingOptionsBuilder setFetcher(final Fetcher fetcher) { + this.fetcher = Optional.of(fetcher); + return this; + } + + public LoadingOptionsBuilder copiedFrom(final LoadingOptions copyFrom) { + this.copyFrom = Optional.of(copyFrom); + return this; + } + + public LoadingOptionsBuilder setFileUri(final String fileUri) { + this.fileUri = Optional.of(fileUri); + return this; + } + + public LoadingOptionsBuilder setNamespaces(final Map<String, String> namespaces) { + this.namespaces = Optional.of(namespaces); + return this; + } + + public LoadingOptions build() { + Fetcher fetcher = this.fetcher.orElse(null); + String fileUri = this.fileUri.orElse(null); + List<String> schemas = this.schemas.orElse(null); + Map<String, String> namespaces = this.namespaces.orElse(null); + Map<String, Map<String, Object>> idx = new HashMap<String, Map<String, Object>>(); + if (this.copyFrom.isPresent()) { + final LoadingOptions copyFrom = this.copyFrom.get(); + idx = copyFrom.idx; + if (fetcher == null) { + fetcher = copyFrom.fetcher; + } + if (fileUri == null) { + fileUri = copyFrom.fileUri; + } + if (namespaces == null) { + namespaces = copyFrom.namespaces; + schemas = copyFrom.schemas; // Bug in Python codegen? + } + } + if (fetcher == null) { + fetcher = new DefaultFetcher(); + } + return new LoadingOptions(fetcher, fileUri, namespaces, schemas, idx); + } +}