Revert polish on Bean Override support
This commit revers the removal of the `private` keyword in the examples of the reference documentation and the tests for consistency. While the default visibility makes the example more concise, it could imply to the reader that the field (or the factory method) cannot be private. Also, there is no need to multiply anything returned from `Objects.hash` as its very distinct on its own already.
This commit is contained in:
		
							parent
							
								
									dc2c8d6094
								
							
						
					
					
						commit
						2d48371c6d
					
				|  | @ -43,7 +43,7 @@ Java:: | ||||||
| ---- | ---- | ||||||
| 	class OverrideBeanTests { | 	class OverrideBeanTests { | ||||||
| 		@MockitoBean // <1> | 		@MockitoBean // <1> | ||||||
| 		CustomService customService; | 		private CustomService customService; | ||||||
| 
 | 
 | ||||||
| 		// test case body... | 		// test case body... | ||||||
| 	} | 	} | ||||||
|  | @ -67,7 +67,7 @@ Java:: | ||||||
| ---- | ---- | ||||||
| 	class OverrideBeanTests { | 	class OverrideBeanTests { | ||||||
| 		@MockitoBean(name = "service") // <1> | 		@MockitoBean(name = "service") // <1> | ||||||
| 		CustomService customService; | 		private CustomService customService; | ||||||
| 
 | 
 | ||||||
| 		// test case body... | 		// test case body... | ||||||
| 
 | 
 | ||||||
|  | @ -88,7 +88,7 @@ Java:: | ||||||
| ---- | ---- | ||||||
| 	class OverrideBeanTests { | 	class OverrideBeanTests { | ||||||
| 		@MockitoSpyBean // <1> | 		@MockitoSpyBean // <1> | ||||||
| 		CustomService customService; | 		private CustomService customService; | ||||||
| 
 | 
 | ||||||
| 		// test case body... | 		// test case body... | ||||||
| 	} | 	} | ||||||
|  | @ -111,7 +111,7 @@ Java:: | ||||||
| ---- | ---- | ||||||
| 	class OverrideBeanTests { | 	class OverrideBeanTests { | ||||||
| 		@MockitoSpyBean(name = "service") // <1> | 		@MockitoSpyBean(name = "service") // <1> | ||||||
| 		CustomService customService; | 		private CustomService customService; | ||||||
| 
 | 
 | ||||||
| 		// test case body... | 		// test case body... | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -36,11 +36,11 @@ Java:: | ||||||
| ---- | ---- | ||||||
| 	class OverrideBeanTests { | 	class OverrideBeanTests { | ||||||
| 		@TestBean // <1> | 		@TestBean // <1> | ||||||
| 		CustomService customService; | 		private CustomService customService; | ||||||
| 
 | 
 | ||||||
| 		// test case body... | 		// test case body... | ||||||
| 
 | 
 | ||||||
| 		static CustomService customService() { // <2> | 		private static CustomService customService() { // <2> | ||||||
| 			return new MyFakeCustomService(); | 			return new MyFakeCustomService(); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -64,11 +64,11 @@ Java:: | ||||||
| ---- | ---- | ||||||
| 	class OverrideBeanTests { | 	class OverrideBeanTests { | ||||||
| 		@TestBean(name = "service", methodName = "createCustomService") // <1> | 		@TestBean(name = "service", methodName = "createCustomService") // <1> | ||||||
| 		CustomService customService; | 		private CustomService customService; | ||||||
| 
 | 
 | ||||||
| 		// test case body... | 		// test case body... | ||||||
| 
 | 
 | ||||||
| 		static CustomService createCustomService() { // <2> | 		private static CustomService createCustomService() { // <2> | ||||||
| 			return new MyFakeCustomService(); | 			return new MyFakeCustomService(); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -80,9 +80,9 @@ public abstract class OverrideMetadata { | ||||||
| 	 * @return a list of {@code OverrideMetadata} | 	 * @return a list of {@code OverrideMetadata} | ||||||
| 	 */ | 	 */ | ||||||
| 	public static List<OverrideMetadata> forTestClass(Class<?> testClass) { | 	public static List<OverrideMetadata> forTestClass(Class<?> testClass) { | ||||||
| 		List<OverrideMetadata> metadataList = new LinkedList<>(); | 		List<OverrideMetadata> metadata = new LinkedList<>(); | ||||||
| 		ReflectionUtils.doWithFields(testClass, field -> parseField(field, testClass, metadataList)); | 		ReflectionUtils.doWithFields(testClass, field -> parseField(field, testClass, metadata)); | ||||||
| 		return metadataList; | 		return metadata; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private static void parseField(Field field, Class<?> testClass, List<OverrideMetadata> metadataList) { | 	private static void parseField(Field field, Class<?> testClass, List<OverrideMetadata> metadataList) { | ||||||
|  | @ -185,7 +185,7 @@ public abstract class OverrideMetadata { | ||||||
| 	public int hashCode() { | 	public int hashCode() { | ||||||
| 		int hash = Objects.hash(getClass(), this.beanType.getType(), this.beanName, this.strategy); | 		int hash = Objects.hash(getClass(), this.beanType.getType(), this.beanName, this.strategy); | ||||||
| 		return (this.beanName != null ? hash : hash + | 		return (this.beanName != null ? hash : hash + | ||||||
| 				31 * Objects.hash(this.field.getName(), Arrays.hashCode(this.field.getAnnotations()))); | 				Objects.hash(this.field.getName(), Arrays.hashCode(this.field.getAnnotations()))); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
|  |  | ||||||
|  | @ -231,27 +231,27 @@ public class OverrideMetadataTests { | ||||||
| 
 | 
 | ||||||
| 	public static class ConfigA { | 	public static class ConfigA { | ||||||
| 
 | 
 | ||||||
| 		ExampleService noQualifier; | 		private ExampleService noQualifier; | ||||||
| 
 | 
 | ||||||
| 		@Qualifier("test") | 		@Qualifier("test") | ||||||
| 		ExampleService directQualifier; | 		private ExampleService directQualifier; | ||||||
| 
 | 
 | ||||||
| 		@Qualifier("different") | 		@Qualifier("different") | ||||||
| 		ExampleService differentDirectQualifier; | 		private ExampleService differentDirectQualifier; | ||||||
| 
 | 
 | ||||||
| 		@CustomQualifier | 		@CustomQualifier | ||||||
| 		ExampleService customQualifier; | 		private ExampleService customQualifier; | ||||||
| 
 | 
 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public static class ConfigB { | 	public static class ConfigB { | ||||||
| 
 | 
 | ||||||
| 		ExampleService noQualifier; | 		private ExampleService noQualifier; | ||||||
| 
 | 
 | ||||||
| 		ExampleService example; | 		private ExampleService example; | ||||||
| 
 | 
 | ||||||
| 		@Qualifier("test") | 		@Qualifier("test") | ||||||
| 		ExampleService directQualifier; | 		private ExampleService directQualifier; | ||||||
| 
 | 
 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -89,7 +89,7 @@ class TestBeanContextCustomizerEqualityTests { | ||||||
| 		@TestBean | 		@TestBean | ||||||
| 		private String description; | 		private String description; | ||||||
| 
 | 
 | ||||||
| 		static String description() { | 		private static String description() { | ||||||
| 			return "overridden"; | 			return "overridden"; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -99,7 +99,7 @@ class TestBeanContextCustomizerEqualityTests { | ||||||
| 		@TestBean(name = "descriptionBean") | 		@TestBean(name = "descriptionBean") | ||||||
| 		private String description; | 		private String description; | ||||||
| 
 | 
 | ||||||
| 		static String description() { | 		private static String description() { | ||||||
| 			return "overridden"; | 			return "overridden"; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue