Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
breaking: Name are composed by a Type and a String
Before the Name was a couple (Class, String), from now on it's a couple (Type, String). The string stay the same, but the Class becomes a Type. Like this we will have a better granularity in order to inject parameterized types. This commit is breaking because the Name class was having a public constructor with a class, and the class have been changed to a Type. WIP: Should we really have a public constructor ?! Personally I think that only private constructors and public static factories should be enough. If you want to build a name with a type, there is multiple solutions. If you want to use a simple generic type (only one depth of generic) like `SomeGeneric<SomeType>`, the easiest way is to use this signature: ```java Name.of(aStringName, SomeGeneric.class, SomeType.class) ``` This method is using the `Types.newParameterizedType` static factory, which is an easy way to build parameterized types. An equivalent technique would be to use something like this: ```java Name.of(Types.newParameterizedType(SomeGeneric.class, SomeType.class), aStringName) ``` (It will be almost equivalent, as the first way will be a little bit more efficient, as the raw type will not be calculated, it is already given in parameter: `SomeGeneric.class`) If you need to build a complex generic type, like `One<Two<Three, Four<Five>>>`, the easiest way will be to use the abstract class `TypeReference` like this: ```java Name.of(new TypeReference<One<Two<Three, Four<Five>>>() {}, aStringName) ```
- Loading branch information
Showing
with
98 additions
and 26 deletions.