Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 1015 Bytes

Spring-ComparisonPropertySource.md

File metadata and controls

43 lines (34 loc) · 1015 Bytes

Spring ComparisonPropertySource

  • Author: HuiFer

  • 源码阅读仓库: SourceHot-spring

  • 整体代码如下.

    • 下面几个调用方法会直接抛出异常
      1. getSource
      2. containsProperty
      3. getProperty
	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);
		}
	}