Spring ComparisonPropertySource

  • Author: HuiFer

  • 源码阅读仓库: SourceHot-spring

  • 整体代码如下.

    • 下面几个调用方法会直接抛出异常
      1. getSource
      2. containsProperty
      3. getProperty
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
	static class ComparisonPropertySource extends StubPropertySource {

		// 异常信息
		private static final String USAGE_ERROR =
				"ComparisonPropertySource instances are for use with collection comparison only";

		public ComparisonPropertySource(String name) {
			super(name);
		}

		@Override
		public Object getSource() {
			// 抛异常
			throw new UnsupportedOperationException(USAGE_ERROR);
		}

		@Override
		public boolean containsProperty(String name) {
			// 抛异常
			throw new UnsupportedOperationException(USAGE_ERROR);
		}

		@Override
		@Nullable
		public String getProperty(String name) {
			// 抛异常
			throw new UnsupportedOperationException(USAGE_ERROR);
		}
	}