2 Sebastian Hoß <https://github.com/sebhoss[@sebhoss]>
4 :project-name: generic-types
5 :project-group: com.github.sebhoss.utils
6 :coverity-project: 7620
8 :toc-placement: preamble
11 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}"]
12 image:https://www.openhub.net/p/{project-name}/widgets/project_thin_badge.gif["Open Hub statistics", link="https://www.ohloh.net/p/{project-name}"]
13 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}"]
14 image:https://img.shields.io/coveralls/{github-org}/{project-name}/master.svg?style=flat-square["", link="https://coveralls.io/github/{github-org}/{project-name}"]
15 image:https://scan.coverity.com/projects/{coverity-project}/badge.svg["Coverity Scan Result", link="https://scan.coverity.com/projects/{coverity-project}"]
16 image:https://badges.gitter.im/Join%20Chat.svg["Gitter", link="https://gitter.im/{github-org}/{project-name}"]
19 This https://www.java.com[Java] library provides a factory to create generic `java.lang.reflect.Type` variations, such as `Map<Number, Point>`.
23 * Factory methods to create generic types, including wildcards.
25 === Development Status
27 All currently required feature are implemented. This project is in maintenance mode.
35 final Type type = GenericTypes.generic(Map.class, Number.class, Point.class);
38 final Type type = GenericTypes.generic(List.class, Number.class);
41 Super- and subtypes such as `List<? super Point>` or `List<? extends Number>` can be created in the following way:
45 // List<? super Point>
46 final Type type = GenericTypes.generic(List.class, GenericTypes.supertype(Point.class));
48 // List<? extends Number>
49 final Type type = GenericTypes.generic(List.class, GenericTypes.subtype(Number.class));
52 Use static imports to shorten the above calls to:
56 // List<? super Point>
57 final Type type = generic(List.class, supertype(Point.class));
59 // List<? extends Number>
60 final Type type = generic(List.class, subtype(Number.class));
63 and then go crazy with this:
67 // List<Map<? extends Number, ? super Point>>
68 final Type type = generic(List.class, generic(Map.class, subtype(Number.class), supertype(Point.class)));
73 To use this project just declare the following dependency inside your POM:
75 [source,xml,subs="attributes,verbatim"]
79 <groupId>{project-group}</groupId>
80 <artifactId>{project-name}</artifactId>
81 <version>${version.generic-types}</version>
86 Replace `${version.generic-types}` with the link:http://search.maven.org/#search%7Cga%7C1%7Cg%3A{project-group}%20a%3A{project-name}[latest release]. This project follows the link:http://semver.org/[semantic versioning guidelines].
91 This project is compatible with the following Java versions:
103 This project is licensed under the link:http://unlicense.org/[UNLICENSE]. See the link:UNLICENSE[UNLICENSE file] for more information.