Search in sources :

Example 1 with Decoder

use of aQute.lib.json.Decoder in project bnd by bndtools.

the class Index method init.

private void init() throws Exception {
    if (repo == null) {
        cache = new TreeMap<String, TreeMap<Version, Library.RevisionRef>>();
        if (indexFile.isFile() && indexFile.length() > 100) {
            try (Decoder dec = codec.dec()) {
                repo = dec.from(indexFile).get(new TypeReference<Repo>() {
                });
                for (Library.RevisionRef r : repo.revisionRefs) {
                    TreeMap<Version, Library.RevisionRef> map = cache.get(r.bsn);
                    if (map == null) {
                        map = new TreeMap<Version, Library.RevisionRef>(Collections.reverseOrder());
                        cache.put(r.bsn, map);
                    }
                    Version v = toVersion(r.baseline, r.qualifier);
                    map.put(v, r);
                }
            }
        } else {
            repo = new Repo();
        }
    }
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef) RevisionRef(aQute.service.library.Library.RevisionRef) Version(aQute.bnd.version.Version) Library(aQute.service.library.Library) TypeReference(aQute.lib.converter.TypeReference) TreeMap(java.util.TreeMap) Decoder(aQute.lib.json.Decoder)

Aggregations

Version (aQute.bnd.version.Version)1 TypeReference (aQute.lib.converter.TypeReference)1 Decoder (aQute.lib.json.Decoder)1 Library (aQute.service.library.Library)1 RevisionRef (aQute.service.library.Library.RevisionRef)1 TreeMap (java.util.TreeMap)1