All Downloads are FREE. Search and download functionalities are using the official Maven repository.

brooklyn.entity.proxying.WrappingEntitySpec Maven / Gradle / Ivy

There is a newer version: 0.7.0-M1
Show newest version
package brooklyn.entity.proxying;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;

import brooklyn.config.ConfigKey;
import brooklyn.entity.Entity;
import brooklyn.policy.Policy;
import brooklyn.util.collections.MutableMap;
import brooklyn.util.collections.MutableSet;

import com.google.common.collect.ImmutableList;

/**
 * @deprecated since 0.6; use {@link EntitySpec#create(EntitySpec)}
 * 
 * @author aled
 */
public class WrappingEntitySpec extends BasicEntitySpec> {

    private final EntitySpec delegate;

    public static  WrappingEntitySpec newInstance(EntitySpec delegate) {
        return new WrappingEntitySpec(delegate);
    }

    public WrappingEntitySpec(EntitySpec delegate) {
        super((Class)delegate.getType());
        this.delegate = delegate;
    }
    
    @Override
    public Class getImplementation() {
        return (super.getImplementation() == null) ? delegate.getImplementation() : super.getImplementation();
    }
    
    @Override
    public Set> getAdditionalInterfaces() {
        return Collections.unmodifiableSet(MutableSet.>builder()
                .addAll(super.getAdditionalInterfaces())
                .addAll(delegate.getAdditionalInterfaces())
                .build());
    }
    
    @Override
    public List getInitializers() {
        return ImmutableList.builder()
                .addAll(super.getInitializers())
                .addAll(delegate.getInitializers())
                .build();
    }
    
    @Override
    public Entity getParent() {
        return (super.getParent() == null) ? delegate.getParent() : super.getParent();
    }
    
    @Override
    public String getDisplayName() {
        return (super.getDisplayName() == null) ? delegate.getDisplayName() : super.getDisplayName();
    }

    @Override
    public List getPolicies() {
        return ImmutableList.builder()
                .addAll(delegate.getPolicies())
                .addAll(super.getPolicies())
                .build();
    }
    
    @Override
    public Map getFlags() {
        return Collections.unmodifiableMap(MutableMap.builder()
                .putAll(delegate.getFlags())
                .putAll(super.getFlags())
                .build());
    }
    
    public Map, Object> getConfig() {
        return Collections.unmodifiableMap(MutableMap.,Object>builder()
                .putAll(delegate.getConfig())
                .putAll(super.getConfig())
                .build());
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy