addFirstPropertySource method

void addFirstPropertySource(
  1. PropertySource propertySource
)

Adds the given propertySource to the start of the composite chain.

This method ensures that the new source receives the highest precedence when resolving properties—its values are checked before all others.

Internally, the existing sources are temporarily copied, the composite is cleared, and the new source is inserted first, followed by the previously present sources in their original order.

Use this method when a new configuration source must override existing entries, such as:

  • in-memory overrides
  • command-line arguments
  • profile-specific configuration

Implementation

void addFirstPropertySource(PropertySource propertySource) {
  final existing = ArrayList<PropertySource>.from(_propertySources);
  _propertySources.clear();
  _propertySources.add(propertySource);
  _propertySources.addAll(existing);
}