Add default implementations of deprecated methods of BuilableItem and Item. (#3142)

* Add default implementations to deprecated methods of BuilableItem and Item.

Currently the interface requires the API user to implement already deprecated methods.
It does not make much sense, and the API could be simplified.

* Address comments from @jglick
This commit is contained in:
Oleg Nenashev authored and GitHub committed 2017-12-01 10:00:49 +03:00
1 parent b32bc8d277
commit 8824857752
5 files changed
+63 -54

No files matched your search

+21 -10
View File
@@ -125,6 +125,7 @@ import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@@ -1142,13 +1143,17 @@ public class Functions {
* Gets the relative name or display name to the given item from the specified group.
*
* @since 1.515
* @param p the Item we want the relative display name
* @param g the ItemGroup used as point of reference for the item
* @param p the Item we want the relative display name.
* If {@code null}, a {@code null} will be returned by the method
* @param g the ItemGroup used as point of reference for the item.
* If the group is not specified, item's path will be used.
* @param useDisplayName if true, returns a display name, otherwise returns a name
* @return
* String like "foo » bar"
* String like "foo » bar".
* {@code null} if item is null or if one of its parents is not an {@link Item}.
*/
public static String getRelativeNameFrom(Item p, ItemGroup g, boolean useDisplayName) {
@Nullable
public static String getRelativeNameFrom(@CheckForNull Item p, @CheckForNull ItemGroup g, boolean useDisplayName) {
if (p == null) return null;
if (g == null) return useDisplayName ? p.getFullDisplayName() : p.getFullName();
String separationString = useDisplayName ? " » " : "/";
@@ -1182,7 +1187,7 @@ public class Functions {
if (gr instanceof Item)
i = (Item)gr;
else
else // Parent is a group, but not an item
return null;
}
}
@@ -1192,11 +1197,14 @@ public class Functions {
*
* @since 1.515
* @param p the Item we want the relative display name
* If {@code null}, the method will immediately return {@code null}.
* @param g the ItemGroup used as point of reference for the item
* @return
* String like "foo/bar"
* String like "foo/bar".
* {@code null} if the item is {@code null} or if one of its parents is not an {@link Item}.
*/
public static String getRelativeNameFrom(Item p, ItemGroup g) {
@Nullable
public static String getRelativeNameFrom(@CheckForNull Item p, @CheckForNull ItemGroup g) {
return getRelativeNameFrom(p, g, false);
}
@@ -1205,12 +1213,15 @@ public class Functions {
* Gets the relative display name to the given item from the specified group.
*
* @since 1.512
* @param p the Item we want the relative display name
* @param p the Item we want the relative display name.
* If {@code null}, the method will immediately return {@code null}.
* @param g the ItemGroup used as point of reference for the item
* @return
* String like "Foo » Bar"
* String like "Foo » Bar".
* {@code null} if the item is {@code null} or if one of its parents is not an {@link Item}.
*/
public static String getRelativeDisplayNameFrom(Item p, ItemGroup g) {
@Nullable
public static String getRelativeDisplayNameFrom(@CheckForNull Item p, @CheckForNull ItemGroup g) {
return getRelativeNameFrom(p, g, true);
}