package uk.ac.ebi.quickgo.annotation.download.converter.helpers;

import java.util.List;
import java.util.Objects;
import java.util.function.Function;

/**
 * A holder for general helper code.
 *
 * @author Tony Wardell
 * Date: 09/04/2018
 * Time: 15:02
 * Created with IntelliJ IDEA.
 */
public class Helper {
    private Helper() {}

    public static final Function<String, String> nullToEmptyString = s -> s == null ? "" : s;

    public static String nullToEmptyString(String reference){
        return Objects.nonNull(reference) ? reference : "";
    }

    public static String nullOrEmptyListToEmptyString(List reference, Function<List, String> mapper){
        return Objects.nonNull(reference) || !reference.isEmpty() ? mapper.apply(reference) : "";
    }

}

@@ -80,74 +80,15 @@
 til.
-List;%0Aimport java.util.Objects;%0Aimport java.util.function.Function
+Objects
 ;%0A%0A/
@@ -279,227 +279,194 @@
     
-public static final Function%3CString, String%3E nullToEmptyString = s -%3E s == null ? %22%22 : s;%0A%0A    public static String nullToE
+/**%0A     * Return the reference if it is no null or empty, otherwise return an e
 mpty
-S
+ s
 tring
-(String reference)%7B%0A  
+.%0A     * @param reference a string value.%0A
      
- 
+* @
 return 
-Objects.nonNull(reference) ? reference : %22%22;
+the reference or empty string.
 %0A    
-%7D%0A
+ */
 %0A   
@@ -495,19 +495,8 @@
 null
-OrEmptyList
 ToEm
@@ -505,20 +505,22 @@
 yString(
-List
+String
  referen
@@ -525,39 +525,8 @@
 ence
-, Function%3CList, String%3E mapper
 )%7B%0A 
@@ -570,47 +570,10 @@
 ce) 
-%7C%7C !reference.isEmpty() ? mapper.apply(
+? 
 refe
@@ -577,17 +577,16 @@
 eference
-)
  : %22%22;%0A 
@@ -590,11 +590,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Remove functional version of nullToEmptyString, add javadoc.