Skip to content

Commit

Permalink
Merge pull request wildfly#6170 from pferraro/WFCORE-6984
Browse files Browse the repository at this point in the history
WFCORE-6984 Allow ResourceDefinition.builder(ResourceRegistration, ResourceDescriptionResolver, SubsystemModel) to accept a null deprecated model
  • Loading branch information
yersan authored Sep 11, 2024
2 parents d25bf47 + d261daa commit a829306
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -181,9 +182,10 @@ default boolean isFeature() {
* @param registration the resource registration
* @param descriptionResolver the resource description resolver
* @return a builder instance
* @throws NullPointerException if {@code registration} or {@code descriptionResolver} were null
*/
static Builder builder(ResourceRegistration registration, ResourceDescriptionResolver descriptionResolver) {
return new MinimalBuilder(registration, descriptionResolver);
return builder(registration, descriptionResolver, null);
}

/**
Expand All @@ -192,18 +194,24 @@ static Builder builder(ResourceRegistration registration, ResourceDescriptionRes
* @param descriptionResolver a resolver of model descriptions for this resource
* @param deprecation the model that deprecates this resource
* @return a builder instance
* @throws NullPointerException if {@code registration} or {@code descriptionResolver} were null
*/
static Builder builder(ResourceRegistration registration, ResourceDescriptionResolver descriptionResolver, SubsystemModel deprecation) {
return new MinimalBuilder(registration, descriptionResolver, new DeprecationData(deprecation.getVersion()));
Objects.requireNonNull(registration);
Objects.requireNonNull(descriptionResolver);
return new MinimalBuilder(registration, descriptionResolver, (deprecation != null) ? new DeprecationData(deprecation.getVersion()) : null);
}

/**
* Creates a {@link ResourceDefinition} builder using the specified registration and description resolver
* @param registration the resource registration
* @param descriptionProvider provides model descriptions for this resource
* @return a builder instance
* @throws NullPointerException if {@code registration} or {@code descriptionProvider} were null
*/
static Builder builder(ResourceRegistration registration, DescriptionProvider descriptionProvider) {
Objects.requireNonNull(registration);
Objects.requireNonNull(descriptionProvider);
return new MinimalBuilder(registration, descriptionProvider);
}

Expand Down Expand Up @@ -379,15 +387,6 @@ interface Builder extends Configurator<Builder> {
*/
static class MinimalBuilder extends AbstractConfigurator<Builder> implements Builder {

MinimalBuilder(ResourceRegistration registration, ResourceDescriptionResolver resolver) {
super(registration, new Function<>() {
@Override
public DescriptionProvider apply(ImmutableManagementResourceRegistration registration) {
return new DefaultResourceDescriptionProvider(registration, resolver);
}
});
}

MinimalBuilder(ResourceRegistration registration, ResourceDescriptionResolver resolver, DeprecationData deprecation) {
super(registration, new Function<>() {
@Override
Expand Down

0 comments on commit a829306

Please sign in to comment.