Skip to content

Commit

Permalink
Deprecate BodyPart name() and filename() to change return type to Opt…
Browse files Browse the repository at this point in the history
…ional<String> in 4.x (#6097)

Add BodyPart.isNamed

Fixes #2833
  • Loading branch information
romain-grecourt authored Feb 7, 2023
1 parent 900cb62 commit 56216e7
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,22 +27,38 @@ public interface BodyPart {

/**
* Get the reactive representation of the part content.
*
* @return {@link MessageBodyContent}, never {@code null}
*/
MessageBodyContent content();

/**
* Returns HTTP part headers.
*
* @return BodyPartHeaders, never {@code null}
*/
BodyPartHeaders headers();

/**
* Test the control name.
*
* @param name the name to test
* @return {@code true} if the {@code name} parameter of the {@code Content-Disposition} header matches,
* {@code false} otherwise
*/
default boolean isNamed(String name) {
return headers().contentDisposition().name().map(name::equals).orElse(false);
}

/**
* Get the control name.
*
* @return the {@code name} parameter of the {@code Content-Disposition}
* header, or {@code null} if not present.
* @deprecated since 3.1.2, this method will be updated to return {@code Optional<String>} in future releases,
* use {@code headers().contentDisposition().name()} instead.
*/
@Deprecated(since = "3.1.2")
default String name() {
return headers().contentDisposition().name().orElse(null);
}
Expand All @@ -52,7 +68,10 @@ default String name() {
*
* @return the {@code filename} parameter of the {@code Content-Disposition}
* header, or {@code null} if not present.
* @deprecated since 3.1.2, this method will be updated to return {@code Optional<String>} in future releases,
* use {@code headers().contentDisposition().filename()} instead.
*/
@Deprecated(since = "3.1.2")
default String filename() {
return headers().contentDisposition().filename().orElse(null);
}
Expand Down

0 comments on commit 56216e7

Please sign in to comment.