提交 701b7b8a 编写于 作者: J Juergen Hoeller

Align ReactiveTypeDescriptor accessor methods

上级 8cd3daad
/*
* 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.
......@@ -84,17 +84,17 @@ public class ReactiveAdapter {
}
/**
* Shortcut for {@code getDescriptor().supportsEmpty()}.
* Shortcut for {@code getDescriptor().isNoValue()}.
*/
public boolean supportsEmpty() {
return getDescriptor().supportsEmpty();
public boolean isNoValue() {
return getDescriptor().isNoValue();
}
/**
* Shortcut for {@code getDescriptor().isNoValue()}.
* Shortcut for {@code getDescriptor().supportsEmpty()}.
*/
public boolean isNoValue() {
return getDescriptor().isNoValue();
public boolean supportsEmpty() {
return getDescriptor().supportsEmpty();
}
......
/*
* 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);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册