Spring EnumerablePropertySource

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

  • 全路径: org.springframework.core.env.EnumerablePropertySource

  • 在这个类中定义了一个抽象方法getPropertyNames 用来获取所有的 property 的名称
  1. public abstract String[] getPropertyNames();
  • 整体代码如下
  1. public abstract class EnumerablePropertySource<T> extends PropertySource<T> {
  2. public EnumerablePropertySource(String name, T source) {
  3. super(name, source);
  4. }
  5. protected EnumerablePropertySource(String name) {
  6. super(name);
  7. }
  8. /**
  9. * Return whether this {@code PropertySource} contains a property with the given name.
  10. * <p>This implementation checks for the presence of the given name within the
  11. * {@link #getPropertyNames()} array.
  12. *
  13. * 在属性列表中是否存在 properties
  14. * @param name the name of the property to find
  15. */
  16. @Override
  17. public boolean containsProperty(String name) {
  18. return ObjectUtils.containsElement(getPropertyNames(), name);
  19. }
  20. /**
  21. * Return the names of all properties contained by the
  22. * 获取所有的 properties 名称
  23. * {@linkplain #getSource() source} object (never {@code null}).
  24. */
  25. public abstract String[] getPropertyNames();
  26. }