Search in sources :

Example 1 with TypeReference

use of aQute.lib.converter.TypeReference in project bnd by bndtools.

the class JSONTest method testGenericsVars.

public void testGenericsVars() {
    ParameterizedType type = (ParameterizedType) new TypeReference<Base<String>>() {
    }.getType();
    System.out.println(type);
    ParameterizedType list = (ParameterizedType) Base.class.getGenericInterfaces()[0];
    System.out.println(list);
    TypeVariable<?> tv = (TypeVariable<?>) list.getActualTypeArguments()[0];
    System.out.println(tv.getGenericDeclaration().getTypeParameters()[0] == tv);
    System.out.println(type.getRawType());
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) TypeVariable(java.lang.reflect.TypeVariable) TypeReference(aQute.lib.converter.TypeReference)

Example 2 with TypeReference

use of aQute.lib.converter.TypeReference 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

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