use new group id
[generic-types.git] / README.asciidoc
blob059d720eeeea48cbbf55ded94b05bffe6e69698a
1 = Generic Types
2 Sebastian Hoß <https://github.com/sebhoss[@sebhoss]>
3 :github-org: sebhoss
4 :project-name: generic-types
5 :project-group: com.github.sebhoss.utils
6 :coverity-project: 7620
7 :toc:
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>`.
21 === Features
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.
30 == Usage
32 [source,java]
33 ----
34 // Map<Number, Point>
35 final Type type = GenericTypes.generic(Map.class, Number.class, Point.class);
37 // List<Number>
38 final Type type = GenericTypes.generic(List.class, Number.class);
39 ----
41 Super- and subtypes such as `List<? super Point>` or `List<? extends Number>` can be created in the following way:
43 [source,java]
44 ----
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));
50 ----
52 Use static imports to shorten the above calls to:
54 [source,java]
55 ----
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));
61 ----
63 and then go crazy with this:
65 [source,java]
66 ----
67 // List<Map<? extends Number, ? super Point>>
68 final Type type = generic(List.class, generic(Map.class, subtype(Number.class), supertype(Point.class)));
69 ----
71 === Integration
73 To use this project just declare the following dependency inside your POM:
75 [source,xml,subs="attributes,verbatim"]
76 ----
77 <dependencies>
78   <dependency>
79     <groupId>{project-group}</groupId>
80     <artifactId>{project-name}</artifactId>
81     <version>${version.generic-types}</version>
82   </dependency>
83 </dependencies>
84 ----
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].
89 === Compatibility
91 This project is compatible with the following Java versions:
93 .Java compatibility
94 |===
95 | | 1.X.Y
97 | Java 8
98 | ✓
99 |===
101 == License
103 This project is licensed under the link:http://unlicense.org/[UNLICENSE]. See the link:UNLICENSE[UNLICENSE file] for more information.