2 Sebastian Hoß <https://github.com/sebhoss[@sebhoss]>
4 :project-name: generic-types
5 :project-group: com.github.sebhoss.utils
6 // :coverity-project: 2658
8 // image:https://img.shields.io/maven-central/v/{project-group}/{project-name}.svg?style=flat-square["Maven Central", link="https://maven-badges.herokuapp.com/maven-central/{project-group}/{project-name}"]
9 image:https://www.openhub.net/p/{project-name}/widgets/project_thin_badge.gif["Open Hub statistics", link="https://www.ohloh.net/p/{project-name}"]
10 image:https://img.shields.io/travis/{github-org}/{project-name}/master.svg?style=flat-square["Build Status", link="https://travis-ci.org/{github-org}/{project-name}"]
11 image:https://img.shields.io/coveralls/{github-org}/{project-name}/master.svg?style=flat-square["", link="https://coveralls.io/github/{github-org}/{project-name}"]
12 // image:https://scan.coverity.com/projects/{coverity-project}/badge.svg["Coverity Scan Result", link="https://scan.coverity.com/projects/{coverity-project}"]
13 // image:https://badges.gitter.im/Join%20Chat.svg["Gitter", link="https://gitter.im/{github-org}/{project-name}"]
15 This Java library provides a factory to create generic `java.lang.reflect.Type` variations, such as `Map<String, Object>`. Use it as follows:
19 final Type genericMap = GenericTypes.generic(Map.class, String.class, Object.class);
20 final Type genericList = GenericTypes.generic(List.class, String.class);
23 Super- and subtypes such as `List<? super Point>` or `List<? extends Number>` can be created in the following way:
27 final Type list = GenericTypes.generic(List.class, GenericTypes.supertype(Point.class));
28 final Type list = GenericTypes.generic(List.class, GenericTypes.subtype(Number.class));
31 Use static imports to shorten the above calls to:
35 final Type list = generic(List.class, supertype(Point.class));
36 final Type list = generic(List.class, subtype(Number.class));
39 and then go crazy with this:
43 final Type type = generic(List.class, generic(Map.class, subtype(Number.class), supertype(String.class)));
46 which represents a `List<Map<? extends Number, ? super String>>`.