org.jboss.as.clustering.controller.SimpleChildResourceProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wildfly-clustering-common Show documentation
Show all versions of wildfly-clustering-common Show documentation
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;
}
}