Example usage for org.springframework.vault.core.util PropertyTransformers removeNullProperties

List of usage examples for org.springframework.vault.core.util PropertyTransformers removeNullProperties

Introduction

In this page you can find the example usage for org.springframework.vault.core.util PropertyTransformers removeNullProperties.

Prototype

public static PropertyTransformer removeNullProperties() 

Source Link

Usage

From source file:org.springframework.vault.core.env.LeaseAwareVaultPropertySource.java

/**
 * Create a new {@link LeaseAwareVaultPropertySource} given a {@code name},
 * {@link SecretLeaseContainer} and {@link RequestedSecret}. This property source
 * requests the secret upon initialization and receives secrets once they are emitted
 * through events published by {@link SecretLeaseContainer}.
 *
 * @param name name of the property source, must not be {@literal null}.
 * @param secretLeaseContainer must not be {@literal null}.
 * @param requestedSecret must not be {@literal null}.
 * @param propertyTransformer object to transform properties.
 * @see PropertyTransformers//from  ww  w  .ja va2 s  . com
 */
public LeaseAwareVaultPropertySource(String name, SecretLeaseContainer secretLeaseContainer,
        RequestedSecret requestedSecret, PropertyTransformer propertyTransformer) {

    super(name);

    Assert.notNull(secretLeaseContainer, "Path name must contain at least one character");
    Assert.notNull(requestedSecret, "SecretLeaseContainer must not be null");
    Assert.notNull(propertyTransformer, "PropertyTransformer must not be null");

    this.secretLeaseContainer = secretLeaseContainer;
    this.requestedSecret = requestedSecret;
    this.propertyTransformer = propertyTransformer.andThen(PropertyTransformers.removeNullProperties());
    this.leaseListener = new LeaseListenerAdapter() {
        @Override
        public void onLeaseEvent(SecretLeaseEvent leaseEvent) {
            handleLeaseEvent(leaseEvent, LeaseAwareVaultPropertySource.this.properties);
        }
    };

    loadProperties();
}