Align ReactiveTypeDescriptor accessor methods
This commit is contained in:
parent
8cd3daad0d
commit
701b7b8a18
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -83,13 +83,6 @@ public class ReactiveAdapter {
|
|||
return getDescriptor().isMultiValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for {@code getDescriptor().supportsEmpty()}.
|
||||
*/
|
||||
public boolean supportsEmpty() {
|
||||
return getDescriptor().supportsEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for {@code getDescriptor().isNoValue()}.
|
||||
*/
|
||||
|
|
@ -97,6 +90,13 @@ public class ReactiveAdapter {
|
|||
return getDescriptor().isNoValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for {@code getDescriptor().supportsEmpty()}.
|
||||
*/
|
||||
public boolean supportsEmpty() {
|
||||
return getDescriptor().supportsEmpty();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adapt the given instance to a Reactive Streams {@code Publisher}.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -23,7 +23,7 @@ import org.springframework.util.Assert;
|
|||
|
||||
/**
|
||||
* Describes the semantics of a reactive type including boolean checks for
|
||||
* {@link #isMultiValue()}, {@link #supportsEmpty()}, and {@link #isNoValue()}.
|
||||
* {@link #isMultiValue()}, {@link #isNoValue()}, and {@link #supportsEmpty()}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
|
|
@ -32,25 +32,25 @@ public final class ReactiveTypeDescriptor {
|
|||
|
||||
private final Class<?> reactiveType;
|
||||
|
||||
@Nullable
|
||||
private final Supplier<?> emptyValueSupplier;
|
||||
|
||||
private final boolean multiValue;
|
||||
|
||||
private final boolean noValue;
|
||||
|
||||
@Nullable
|
||||
private final Supplier<?> emptyValueSupplier;
|
||||
|
||||
|
||||
/**
|
||||
* Private constructor. See static factory methods.
|
||||
*/
|
||||
private ReactiveTypeDescriptor(Class<?> reactiveType, @Nullable Supplier<?> emptySupplier,
|
||||
boolean multiValue, boolean noValue) {
|
||||
private ReactiveTypeDescriptor(Class<?> reactiveType, boolean multiValue, boolean noValue,
|
||||
@Nullable Supplier<?> emptySupplier) {
|
||||
|
||||
Assert.notNull(reactiveType, "'reactiveType' must not be null");
|
||||
this.reactiveType = reactiveType;
|
||||
this.emptyValueSupplier = emptySupplier;
|
||||
this.multiValue = multiValue;
|
||||
this.noValue = noValue;
|
||||
this.emptyValueSupplier = emptySupplier;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -71,13 +71,6 @@ public final class ReactiveTypeDescriptor {
|
|||
return this.multiValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code true} if the reactive type can complete with no values.
|
||||
*/
|
||||
public boolean supportsEmpty() {
|
||||
return (this.emptyValueSupplier != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code true} if the reactive type does not produce any values and
|
||||
* only provides completion and error signals.
|
||||
|
|
@ -86,6 +79,13 @@ public final class ReactiveTypeDescriptor {
|
|||
return this.noValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code true} if the reactive type can complete with no values.
|
||||
*/
|
||||
public boolean supportsEmpty() {
|
||||
return (this.emptyValueSupplier != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an empty-value instance for the underlying reactive or async type.
|
||||
* Use of this type implies {@link #supportsEmpty()} is true.
|
||||
|
|
@ -119,7 +119,7 @@ public final class ReactiveTypeDescriptor {
|
|||
* @param emptySupplier a supplier of an empty-value instance of the reactive type
|
||||
*/
|
||||
public static ReactiveTypeDescriptor multiValue(Class<?> type, Supplier<?> emptySupplier) {
|
||||
return new ReactiveTypeDescriptor(type, emptySupplier, true, false);
|
||||
return new ReactiveTypeDescriptor(type, true, false, emptySupplier);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -128,7 +128,7 @@ public final class ReactiveTypeDescriptor {
|
|||
* @param emptySupplier a supplier of an empty-value instance of the reactive type
|
||||
*/
|
||||
public static ReactiveTypeDescriptor singleOptionalValue(Class<?> type, Supplier<?> emptySupplier) {
|
||||
return new ReactiveTypeDescriptor(type, emptySupplier, false, false);
|
||||
return new ReactiveTypeDescriptor(type, false, false, emptySupplier);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -136,7 +136,7 @@ public final class ReactiveTypeDescriptor {
|
|||
* @param type the reactive type
|
||||
*/
|
||||
public static ReactiveTypeDescriptor singleRequiredValue(Class<?> type) {
|
||||
return new ReactiveTypeDescriptor(type, null, false, false);
|
||||
return new ReactiveTypeDescriptor(type, false, false, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -145,7 +145,7 @@ public final class ReactiveTypeDescriptor {
|
|||
* @param emptySupplier a supplier of an empty-value instance of the reactive type
|
||||
*/
|
||||
public static ReactiveTypeDescriptor noValue(Class<?> type, Supplier<?> emptySupplier) {
|
||||
return new ReactiveTypeDescriptor(type, emptySupplier, false, true);
|
||||
return new ReactiveTypeDescriptor(type, false, true, emptySupplier);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue