package uk.ac.ebi.quickgo.annotation.model;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Tony Wardell
 * Date: 20/01/2017
 * Time: 17:01
 * Created with IntelliJ IDEA.
 */
public class ConversionUtil {

    private static final String COMMA = ",";
    private static final String PIPE = "|";

    public String withFromAsString(List<Annotation.ConnectedXRefs> connectedXRefs) {
        return connectedXRefs.stream()
                             .map(itemList -> simpleRefAndToString(itemList))
                             .collect(Collectors.joining(PIPE));
    }

    private String simpleRefAndToString(Annotation.ConnectedXRefs itemList) {
        return itemList.getConnectedXrefs()
                       .stream()
                       .map(cr -> {
                           Annotation.SimpleXRef sr = ((Annotation.SimpleXRef) cr);
                           return sr.asXref();
                       })
                       .collect(Collectors.joining(COMMA)).toString();

    }

    public String extensionsAsString(List<Annotation.ConnectedXRefs> connectedXRefs) {
        return connectedXRefs.stream()
                             .map(itemList -> qualifiedRefAndToString(itemList))
                             .collect(Collectors.joining(PIPE));
    }

    private String qualifiedRefAndToString(Annotation.ConnectedXRefs itemList) {
        return itemList.getConnectedXrefs()
                       .stream()
                       .map(cr -> {
                           Annotation.QualifiedXref sr = ((Annotation.QualifiedXref) cr);
                           return sr.asXref();
                       })
                       .collect(Collectors.joining(COMMA)).toString();
    }

    private static final String ID_DELIMITER = ":";
    public String[] idToComponents(Annotation annotation) {

        return annotation.id.split(ID_DELIMITER);
    }
}

@@ -54,59 +54,231 @@
 ava.
-util.List;%0Aimport java.util.stream.Collectors;%0A%0A/**
+text.DateFormat;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Date;%0Aimport java.util.List;%0Aimport java.util.stream.Collectors;%0A%0A/**%0A * This class contains methods that are shared between the AnnotationToX converters.
 %0A * 
@@ -487,16 +487,109 @@
 E = %22%7C%22;
+%0A    private static final DateFormat YYYYMMDD_DATE_FORMAT = new SimpleDateFormat(%22yyyyMMdd%22);
 %0A%0A    pu
@@ -2165,11 +2165,105 @@
 );%0A    %7D
+%0A%0A    public String toYMD(Date date) %7B%0A        return YYYYMMDD_DATE_FORMAT.format(date);%0A    %7D
 %0A%7D%0A

Add YMD method.