org.springframework.core.ResolvableType.VariableResolver Java Examples
The following examples show how to use
org.springframework.core.ResolvableType.VariableResolver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResolvableTypeTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void resolveTypeWithCustomVariableResolver() throws Exception { VariableResolver variableResolver = mock(VariableResolver.class); given(variableResolver.getSource()).willReturn(this); ResolvableType longType = ResolvableType.forClass(Long.class); given(variableResolver.resolveVariable(any())).willReturn(longType); ResolvableType variable = ResolvableType.forType( Fields.class.getField("typeVariableType").getGenericType(), variableResolver); ResolvableType parameterized = ResolvableType.forType( Fields.class.getField("parameterizedType").getGenericType(), variableResolver); assertThat(variable.resolve(), equalTo((Class) Long.class)); assertThat(parameterized.resolve(), equalTo((Class) List.class)); assertThat(parameterized.resolveGeneric(), equalTo((Class) Long.class)); verify(variableResolver, atLeastOnce()).resolveVariable(this.typeVariableCaptor.capture()); assertThat(this.typeVariableCaptor.getValue().getName(), equalTo("T")); }
Example #2
Source File: ResolvableTypeTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void hashCodeAndEquals() throws Exception { ResolvableType forClass = ResolvableType.forClass(List.class); ResolvableType forFieldDirect = ResolvableType.forField(Fields.class.getDeclaredField("stringList")); ResolvableType forFieldViaType = ResolvableType.forType(Fields.class.getDeclaredField("stringList").getGenericType(), (VariableResolver) null); ResolvableType forFieldWithImplementation = ResolvableType.forField(Fields.class.getDeclaredField("stringList"), TypedFields.class); assertThat(forClass, equalTo(forClass)); assertThat(forClass.hashCode(), equalTo(forClass.hashCode())); assertThat(forClass, not(equalTo(forFieldDirect))); assertThat(forClass, not(equalTo(forFieldWithImplementation))); assertThat(forFieldDirect, equalTo(forFieldDirect)); assertThat(forFieldDirect, not(equalTo(forFieldViaType))); assertThat(forFieldDirect, not(equalTo(forFieldWithImplementation))); }
Example #3
Source File: ResolvableTypeTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void resolveTypeWithCustomVariableResolver() throws Exception { VariableResolver variableResolver = mock(VariableResolver.class); given(variableResolver.getSource()).willReturn(this); ResolvableType longType = ResolvableType.forClass(Long.class); given(variableResolver.resolveVariable(any())).willReturn(longType); ResolvableType variable = ResolvableType.forType( Fields.class.getField("typeVariableType").getGenericType(), variableResolver); ResolvableType parameterized = ResolvableType.forType( Fields.class.getField("parameterizedType").getGenericType(), variableResolver); assertThat(variable.resolve(), equalTo((Class) Long.class)); assertThat(parameterized.resolve(), equalTo((Class) List.class)); assertThat(parameterized.resolveGeneric(), equalTo((Class) Long.class)); verify(variableResolver, atLeastOnce()).resolveVariable(this.typeVariableCaptor.capture()); assertThat(this.typeVariableCaptor.getValue().getName(), equalTo("T")); }
Example #4
Source File: ResolvableTypeTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void hashCodeAndEquals() throws Exception { ResolvableType forClass = ResolvableType.forClass(List.class); ResolvableType forFieldDirect = ResolvableType.forField(Fields.class.getDeclaredField("stringList")); ResolvableType forFieldViaType = ResolvableType.forType(Fields.class.getDeclaredField("stringList").getGenericType(), (VariableResolver) null); ResolvableType forFieldWithImplementation = ResolvableType.forField(Fields.class.getDeclaredField("stringList"), TypedFields.class); assertThat(forClass, equalTo(forClass)); assertThat(forClass.hashCode(), equalTo(forClass.hashCode())); assertThat(forClass, not(equalTo(forFieldDirect))); assertThat(forClass, not(equalTo(forFieldWithImplementation))); assertThat(forFieldDirect, equalTo(forFieldDirect)); assertThat(forFieldDirect, not(equalTo(forFieldViaType))); assertThat(forFieldDirect, not(equalTo(forFieldWithImplementation))); }
Example #5
Source File: ResolvableTypeTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void resolveTypeWithCustomVariableResolver() throws Exception { VariableResolver variableResolver = mock(VariableResolver.class); given(variableResolver.getSource()).willReturn(this); ResolvableType longType = ResolvableType.forClass(Long.class); given(variableResolver.resolveVariable((TypeVariable<?>) anyObject())).willReturn(longType); ResolvableType variable = ResolvableType.forType( Fields.class.getField("typeVariableType").getGenericType(), variableResolver); ResolvableType parameterized = ResolvableType.forType( Fields.class.getField("parameterizedType").getGenericType(), variableResolver); assertThat(variable.resolve(), equalTo((Class) Long.class)); assertThat(parameterized.resolve(), equalTo((Class) List.class)); assertThat(parameterized.resolveGeneric(), equalTo((Class) Long.class)); verify(variableResolver, atLeastOnce()).resolveVariable(this.typeVariableCaptor.capture()); assertThat(this.typeVariableCaptor.getValue().getName(), equalTo("T")); }
Example #6
Source File: ResolvableTypeTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void hashCodeAndEquals() throws Exception { ResolvableType forClass = ResolvableType.forClass(List.class); ResolvableType forFieldDirect = ResolvableType.forField(Fields.class.getDeclaredField("stringList")); ResolvableType forFieldViaType = ResolvableType.forType(Fields.class.getDeclaredField("stringList").getGenericType(), (VariableResolver) null); ResolvableType forFieldWithImplementation = ResolvableType.forField(Fields.class.getDeclaredField("stringList"), TypedFields.class); assertThat(forClass, equalTo(forClass)); assertThat(forClass.hashCode(), equalTo(forClass.hashCode())); assertThat(forClass, not(equalTo(forFieldDirect))); assertThat(forClass, not(equalTo(forFieldWithImplementation))); assertThat(forFieldDirect, equalTo(forFieldDirect)); assertThat(forFieldDirect, not(equalTo(forFieldViaType))); assertThat(forFieldDirect, not(equalTo(forFieldWithImplementation))); }