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

org.jboss.as.clustering.controller.SimpleChildResourceProvider Maven / Gradle / Ivy

Go to download

The code in this module is not explicitly related to clustering, but rather contains resuable code used by clustering modules and any modules that integrate with clustering.

The newest version!
/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.jboss.as.clustering.controller;

import java.util.Set;
import java.util.function.Supplier;

import org.jboss.as.controller.registry.PlaceholderResource;
import org.jboss.as.controller.registry.Resource;
import org.wildfly.common.function.Functions;

/**
 * A simple {@link ChildResourceProvider} containing a predefined set of children.
 * @author Paul Ferraro
 */
public class SimpleChildResourceProvider implements ChildResourceProvider {

    private final Set children;
    private final Supplier provider;

    public SimpleChildResourceProvider(Set children) {
        this(children, Functions.constantSupplier(PlaceholderResource.INSTANCE));
    }

    public SimpleChildResourceProvider(Set children, Supplier provider) {
        this.children = children;
        this.provider = provider;
    }

    @Override
    public Resource getChild(String name) {
        return this.children.contains(name) ? this.provider.get() : null;
    }

    @Override
    public Set getChildren() {
        return this.children;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy