Spring ComparisonPropertySource

  • Author: HuiFer
  • 源码阅读仓库: SourceHot-spring

  • 整体代码如下.

    • 下面几个调用方法会直接抛出异常
      1. getSource
      2. containsProperty
      3. getProperty
  1. static class ComparisonPropertySource extends StubPropertySource {
  2. // 异常信息
  3. private static final String USAGE_ERROR =
  4. "ComparisonPropertySource instances are for use with collection comparison only";
  5. public ComparisonPropertySource(String name) {
  6. super(name);
  7. }
  8. @Override
  9. public Object getSource() {
  10. // 抛异常
  11. throw new UnsupportedOperationException(USAGE_ERROR);
  12. }
  13. @Override
  14. public boolean containsProperty(String name) {
  15. // 抛异常
  16. throw new UnsupportedOperationException(USAGE_ERROR);
  17. }
  18. @Override
  19. @Nullable
  20. public String getProperty(String name) {
  21. // 抛异常
  22. throw new UnsupportedOperationException(USAGE_ERROR);
  23. }
  24. }