package com.ulisesbocchio.jasyptspringboot.wrapper;

import com.ulisesbocchio.jasyptspringboot.EncryptablePropertyResolver;
import com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource;

import org.jasypt.encryption.StringEncryptor;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * @author Ulises Bocchio
 */
public class EncryptableMapPropertySourceWrapper extends MapPropertySource implements EncryptablePropertySource<Map<String, Object>> {
    EncryptablePropertyResolver resolver;
    private MapPropertySource delegate;

    public EncryptableMapPropertySourceWrapper(MapPropertySource delegate, EncryptablePropertyResolver resolver) {
        super(delegate.getName(), delegate.getSource());
        Assert.notNull(delegate, "PropertySource delegate cannot be null");
        Assert.notNull(resolver, "EncryptablePropertyResolver cannot be null");
        this.resolver = resolver;
        this.delegate = delegate;
    }

    @Override
    public Object getProperty(String name) {
        return getProperty(resolver, delegate, name);
    }

    @Override
    public PropertySource<Map<String, Object>> getDelegate() {
        return delegate;
    }
}

@@ -191,54 +191,8 @@
 e;%0A%0A
-import org.jasypt.encryption.StringEncryptor;%0A
 impo
@@ -1240,11 +1240,235 @@
 e;%0A    %7D
+%0A%0A    @Override%0A    public boolean containsProperty(String name) %7B%0A       return delegate.containsProperty(name);%0A    %7D%0A%0A    @Override%0A    public String%5B%5D getPropertyNames() %7B%0A       return delegate.getPropertyNames();%0A    %7D
 %0A%7D%0A

Fix containsProperty and getPropertyNames on MapPropertySources