ErrorProne: fix base/UnnecessaryParentheses

This commit is contained in:
mkpaz 2023-02-09 14:50:07 +04:00
parent ba9bfc654b
commit 4a0a673bff
2 changed files with 45 additions and 21 deletions

@ -283,7 +283,7 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
final double left = snapSpaceX(getInsets().getLeft()); final double left = snapSpaceX(getInsets().getLeft());
final double right = snapSpaceX(getInsets().getRight()); final double right = snapSpaceX(getInsets().getRight());
final double contentWidth = width - left - right - hGaps; final double contentWidth = width - left - right - hGaps;
return ((snapSizeX(contentWidth / nCols)) * nCols) + left + right + hGaps; return (snapSizeX(contentWidth / nCols) * nCols) + left + right + hGaps;
} }
@Override @Override

@ -173,6 +173,7 @@ public class Popover extends PopupControl {
* Returns the value of the content property * Returns the value of the content property
* *
* @return the content node * @return the content node
*
* @see #contentNodeProperty() * @see #contentNodeProperty()
*/ */
public final Node getContentNode() { public final Node getContentNode() {
@ -183,6 +184,7 @@ public class Popover extends PopupControl {
* Sets the value of the content property. * Sets the value of the content property.
* *
* @param content the new content node value * @param content the new content node value
*
* @see #contentNodeProperty() * @see #contentNodeProperty()
*/ */
public final void setContentNode(Node content) { public final void setContentNode(Node content) {
@ -239,10 +241,10 @@ public class Popover extends PopupControl {
* given owner. If the arrow points up then the popover will be placed * given owner. If the arrow points up then the popover will be placed
* below the given owner node. * below the given owner node.
* *
* @param owner the owner of the popover * @param owner the owner of the popover
* @param offset if negative specifies the distance to the owner node or when * @param offset if negative specifies the distance to the owner node or when
* positive specifies the number of pixels that the arrow will * positive specifies the number of pixels that the arrow will
* overlap with the owner node (positive values are recommended) * overlap with the owner node (positive values are recommended)
*/ */
public final void show(Node owner, double offset) { public final void show(Node owner, double offset) {
requireNonNull(owner); requireNonNull(owner);
@ -301,8 +303,8 @@ public class Popover extends PopupControl {
* of the arrow of the popover and not the location of the window. * of the arrow of the popover and not the location of the window.
* *
* @param owner the owning node * @param owner the owning node
* @param x the x coordinate for the popover arrow tip * @param x the x coordinate for the popover arrow tip
* @param y the y coordinate for the popover arrow tip * @param y the y coordinate for the popover arrow tip
*/ */
@Override @Override
public final void show(Node owner, double x, double y) { public final void show(Node owner, double x, double y) {
@ -314,11 +316,11 @@ public class Popover extends PopupControl {
* the given owner node. The x and y coordinate will be the target location * the given owner node. The x and y coordinate will be the target location
* of the arrow of the popover and not the location of the window. * of the arrow of the popover and not the location of the window.
* *
* @param owner the owning node * @param owner the owning node
* @param x the x coordinate for the popover arrow tip * @param x the x coordinate for the popover arrow tip
* @param y the y coordinate for the popover arrow tip * @param y the y coordinate for the popover arrow tip
* @param fadeInDuration the time it takes for the popover to be fully visible. * @param fadeInDuration the time it takes for the popover to be fully visible.
* This duration takes precedence over the fade-in property without setting. * This duration takes precedence over the fade-in property without setting.
*/ */
public final void show(Node owner, double x, double y, Duration fadeInDuration) { public final void show(Node owner, double x, double y, Duration fadeInDuration) {
/* /*
@ -422,7 +424,7 @@ public class Popover extends PopupControl {
* Hides the popover by quickly changing its opacity to 0. * Hides the popover by quickly changing its opacity to 0.
* *
* @param fadeOutDuration the duration of the fade transition that is being used to * @param fadeOutDuration the duration of the fade transition that is being used to
* change the opacity of the popover * change the opacity of the popover
*/ */
public final void hide(Duration fadeOutDuration) { public final void hide(Duration fadeOutDuration) {
if (fadeOutDuration == null) { if (fadeOutDuration == null) {
@ -487,17 +489,14 @@ public class Popover extends PopupControl {
double prefContentHeight = getContentNode().prefHeight(-1); double prefContentHeight = getContentNode().prefHeight(-1);
return switch (getArrowLocation()) { return switch (getArrowLocation()) {
case LEFT_TOP, RIGHT_TOP -> ( case LEFT_TOP, RIGHT_TOP -> getCornerRadius() + getArrowIndent() + getArrowSize();
case LEFT_CENTER, RIGHT_CENTER -> Math.max(
prefContentHeight, 2 * (getCornerRadius() + getArrowIndent() + getArrowSize())
) / 2;
case LEFT_BOTTOM, RIGHT_BOTTOM -> Math.max(
prefContentHeight - getCornerRadius() - getArrowIndent() - getArrowSize(),
getCornerRadius() + getArrowIndent() + getArrowSize() getCornerRadius() + getArrowIndent() + getArrowSize()
); );
case LEFT_CENTER, RIGHT_CENTER -> (
Math.max(prefContentHeight, 2 * (getCornerRadius() + getArrowIndent() + getArrowSize())) / 2
);
case LEFT_BOTTOM, RIGHT_BOTTOM -> (
Math.max(prefContentHeight - getCornerRadius() - getArrowIndent() - getArrowSize(),
getCornerRadius() + getArrowIndent() + getArrowSize()
)
);
default -> 0; default -> 0;
}; };
} }
@ -526,6 +525,7 @@ public class Popover extends PopupControl {
* Sets the value of the headerAlwaysVisible property. * Sets the value of the headerAlwaysVisible property.
* *
* @param visible if true, then the header is visible even while attached * @param visible if true, then the header is visible even while attached
*
* @see #headerAlwaysVisibleProperty() * @see #headerAlwaysVisibleProperty()
*/ */
public final void setHeaderAlwaysVisible(boolean visible) { public final void setHeaderAlwaysVisible(boolean visible) {
@ -536,6 +536,7 @@ public class Popover extends PopupControl {
* Returns the value of the detachable property. * Returns the value of the detachable property.
* *
* @return true if the header is visible even while attached * @return true if the header is visible even while attached
*
* @see #headerAlwaysVisibleProperty() * @see #headerAlwaysVisibleProperty()
*/ */
public final boolean isHeaderAlwaysVisible() { public final boolean isHeaderAlwaysVisible() {
@ -555,6 +556,7 @@ public class Popover extends PopupControl {
* Sets the value of the closeButtonEnabled property. * Sets the value of the closeButtonEnabled property.
* *
* @param enabled if false, the popover will not be closeable by the header's close button * @param enabled if false, the popover will not be closeable by the header's close button
*
* @see #closeButtonEnabledProperty() * @see #closeButtonEnabledProperty()
*/ */
public final void setCloseButtonEnabled(boolean enabled) { public final void setCloseButtonEnabled(boolean enabled) {
@ -565,6 +567,7 @@ public class Popover extends PopupControl {
* Returns the value of the closeButtonEnabled property. * Returns the value of the closeButtonEnabled property.
* *
* @return true if the header's close button is enabled * @return true if the header's close button is enabled
*
* @see #closeButtonEnabledProperty() * @see #closeButtonEnabledProperty()
*/ */
public final boolean isCloseButtonEnabled() { public final boolean isCloseButtonEnabled() {
@ -584,6 +587,7 @@ public class Popover extends PopupControl {
* Sets the value of the detachable property. * Sets the value of the detachable property.
* *
* @param detachable if true then the user can detach / tear off the popover * @param detachable if true then the user can detach / tear off the popover
*
* @see #detachableProperty() * @see #detachableProperty()
*/ */
public final void setDetachable(boolean detachable) { public final void setDetachable(boolean detachable) {
@ -594,6 +598,7 @@ public class Popover extends PopupControl {
* Returns the value of the detachable property. * Returns the value of the detachable property.
* *
* @return true if the user is allowed to detach / tear off the popover * @return true if the user is allowed to detach / tear off the popover
*
* @see #detachableProperty() * @see #detachableProperty()
*/ */
public final boolean isDetachable() { public final boolean isDetachable() {
@ -617,7 +622,8 @@ public class Popover extends PopupControl {
* Sets the value of the detached property. * Sets the value of the detached property.
* *
* @param detached if true the popover will change its appearance to "detached" * @param detached if true the popover will change its appearance to "detached"
* mode * mode
*
* @see #detachedProperty() * @see #detachedProperty()
*/ */
public final void setDetached(boolean detached) { public final void setDetached(boolean detached) {
@ -628,6 +634,7 @@ public class Popover extends PopupControl {
* Returns the value of the detached property. * Returns the value of the detached property.
* *
* @return true if the popover is currently detached. * @return true if the popover is currently detached.
*
* @see #detachedProperty() * @see #detachedProperty()
*/ */
public final boolean isDetached() { public final boolean isDetached() {
@ -649,6 +656,7 @@ public class Popover extends PopupControl {
* Returns the value of the arrow size property. * Returns the value of the arrow size property.
* *
* @return the arrow size property value * @return the arrow size property value
*
* @see #arrowSizeProperty() * @see #arrowSizeProperty()
*/ */
public final double getArrowSize() { public final double getArrowSize() {
@ -659,6 +667,7 @@ public class Popover extends PopupControl {
* Sets the value of the arrow size property. * Sets the value of the arrow size property.
* *
* @param size the new value of the arrow size property * @param size the new value of the arrow size property
*
* @see #arrowSizeProperty() * @see #arrowSizeProperty()
*/ */
public final void setArrowSize(double size) { public final void setArrowSize(double size) {
@ -681,6 +690,7 @@ public class Popover extends PopupControl {
* Returns the value of the arrow indent property. * Returns the value of the arrow indent property.
* *
* @return the arrow indent value * @return the arrow indent value
*
* @see #arrowIndentProperty() * @see #arrowIndentProperty()
*/ */
public final double getArrowIndent() { public final double getArrowIndent() {
@ -691,6 +701,7 @@ public class Popover extends PopupControl {
* Sets the value of the arrow indent property. * Sets the value of the arrow indent property.
* *
* @param size the arrow indent value * @param size the arrow indent value
*
* @see #arrowIndentProperty() * @see #arrowIndentProperty()
*/ */
public final void setArrowIndent(double size) { public final void setArrowIndent(double size) {
@ -712,6 +723,7 @@ public class Popover extends PopupControl {
* Returns the value of the corner radius property. * Returns the value of the corner radius property.
* *
* @return the corner radius * @return the corner radius
*
* @see #cornerRadiusProperty() * @see #cornerRadiusProperty()
*/ */
public final double getCornerRadius() { public final double getCornerRadius() {
@ -722,6 +734,7 @@ public class Popover extends PopupControl {
* Sets the value of the corner radius property. * Sets the value of the corner radius property.
* *
* @param radius the corner radius * @param radius the corner radius
*
* @see #cornerRadiusProperty() * @see #cornerRadiusProperty()
*/ */
public final void setCornerRadius(double radius) { public final void setCornerRadius(double radius) {
@ -743,6 +756,7 @@ public class Popover extends PopupControl {
* Returns the value of the title property. * Returns the value of the title property.
* *
* @return the detached title * @return the detached title
*
* @see #titleProperty() * @see #titleProperty()
*/ */
public final String getTitle() { public final String getTitle() {
@ -753,6 +767,7 @@ public class Popover extends PopupControl {
* Sets the value of the title property. * Sets the value of the title property.
* *
* @param title the title to use when detached * @param title the title to use when detached
*
* @see #titleProperty() * @see #titleProperty()
*/ */
public final void setTitle(String title) { public final void setTitle(String title) {
@ -769,6 +784,7 @@ public class Popover extends PopupControl {
* location of the arrow if auto fix is enabled. * location of the arrow if auto fix is enabled.
* *
* @return the arrow location property * @return the arrow location property
*
* @see #setAutoFix(boolean) * @see #setAutoFix(boolean)
*/ */
public final ObjectProperty<ArrowLocation> arrowLocationProperty() { public final ObjectProperty<ArrowLocation> arrowLocationProperty() {
@ -779,6 +795,7 @@ public class Popover extends PopupControl {
* Sets the value of the arrow location property. * Sets the value of the arrow location property.
* *
* @param location the requested location * @param location the requested location
*
* @see #arrowLocationProperty() * @see #arrowLocationProperty()
*/ */
public final void setArrowLocation(ArrowLocation location) { public final void setArrowLocation(ArrowLocation location) {
@ -789,6 +806,7 @@ public class Popover extends PopupControl {
* Returns the value of the arrow location property. * Returns the value of the arrow location property.
* *
* @return the preferred arrow location * @return the preferred arrow location
*
* @see #arrowLocationProperty() * @see #arrowLocationProperty()
*/ */
public final ArrowLocation getArrowLocation() { public final ArrowLocation getArrowLocation() {
@ -835,6 +853,7 @@ public class Popover extends PopupControl {
* Returns the value of the fade-in duration property. * Returns the value of the fade-in duration property.
* *
* @return the fade-in duration * @return the fade-in duration
*
* @see #fadeInDurationProperty() * @see #fadeInDurationProperty()
*/ */
public final Duration getFadeInDuration() { public final Duration getFadeInDuration() {
@ -846,6 +865,7 @@ public class Popover extends PopupControl {
* Popover.show(..). * Popover.show(..).
* *
* @param duration the requested fade-in duration * @param duration the requested fade-in duration
*
* @see #fadeInDurationProperty() * @see #fadeInDurationProperty()
*/ */
public final void setFadeInDuration(Duration duration) { public final void setFadeInDuration(Duration duration) {
@ -856,6 +876,7 @@ public class Popover extends PopupControl {
* Returns the value of the fade-out duration property. * Returns the value of the fade-out duration property.
* *
* @return the fade-out duration * @return the fade-out duration
*
* @see #fadeOutDurationProperty() * @see #fadeOutDurationProperty()
*/ */
public final Duration getFadeOutDuration() { public final Duration getFadeOutDuration() {
@ -866,6 +887,7 @@ public class Popover extends PopupControl {
* Sets the value of the fade-out duration property. * Sets the value of the fade-out duration property.
* *
* @param duration the requested fade-out duration * @param duration the requested fade-out duration
*
* @see #fadeOutDurationProperty() * @see #fadeOutDurationProperty()
*/ */
public final void setFadeOutDuration(Duration duration) { public final void setFadeOutDuration(Duration duration) {
@ -886,6 +908,7 @@ public class Popover extends PopupControl {
* Returns the value of the "animated" property. * Returns the value of the "animated" property.
* *
* @return true if the Popover will be shown and hidden with a short fade animation * @return true if the Popover will be shown and hidden with a short fade animation
*
* @see #animatedProperty() * @see #animatedProperty()
*/ */
public final boolean isAnimated() { public final boolean isAnimated() {
@ -896,6 +919,7 @@ public class Popover extends PopupControl {
* Sets the value of the "animated" property. * Sets the value of the "animated" property.
* *
* @param animated if true the Popover will be shown and hidden with a short fade animation * @param animated if true the Popover will be shown and hidden with a short fade animation
*
* @see #animatedProperty() * @see #animatedProperty()
*/ */
public final void setAnimated(boolean animated) { public final void setAnimated(boolean animated) {