package uk.ac.ebi.quickgo.annotation.validation.service;

import com.google.common.base.Preconditions;
import java.util.Objects;

/**
 * Utility methods related to Database Cross Reference ids.
 *
 * @author Tony Wardell
 * Date: 10/11/2016
 * Time: 13:41
 * Created with IntelliJ IDEA.
 */
public class DbCrossReferenceId {

    private static final String DELIMITER = ":";

    public static String db(final String idWithDb) {
        Preconditions.checkArgument(Objects.nonNull(idWithDb), "The id should not be null");
        Preconditions.checkArgument(idWithDb.contains(DELIMITER), "The id should contain the delimiter %s", DELIMITER);
        return idWithDb.substring(0, idWithDb.indexOf(":")).trim();
    }

    public static String id(final String idWithDb){
        Preconditions.checkArgument(Objects.nonNull(idWithDb), "The id should not be null");
        Preconditions.checkArgument(idWithDb.contains(DELIMITER), "The id should contain the delimiter %s", DELIMITER);
        return idWithDb.substring(idWithDb.indexOf(":") + 1).trim();
    }
}

@@ -422,32 +422,37 @@
 thDb) %7B%0A        
+check
 Preconditions.ch
@@ -452,77 +452,17 @@
 ions
-.checkArgument(Objects.nonNull(idWithDb), %22The id should not be null%22
+(idWithDb
 );%0A 
@@ -472,117 +472,162 @@
     
-P
 re
-conditions.checkArgument(idWithDb.contains(DELIMITER), %22The id should contain the delimiter %25s%22, DELIMITER
+turn idWithDb.substring(0, idWithDb.indexOf(%22:%22)).trim();%0A    %7D%0A%0A    public static String id(final String idWithDb)%7B%0A        checkPreconditions(idWithDb
 );%0A 
@@ -651,35 +651,32 @@
 ithDb.substring(
-0, 
 idWithDb.indexOf
@@ -672,32 +672,36 @@
 hDb.indexOf(%22:%22)
+ + 1
 ).trim();%0A    %7D%0A
@@ -702,37 +702,38 @@
     %7D%0A%0A    p
-ublic
+rivate
  static 
 String id(fi
@@ -720,32 +720,40 @@
  static 
-String id(final 
+void checkPreconditions(
 String i
@@ -752,32 +752,33 @@
 String idWithDb)
+ 
 %7B%0A        Precon
@@ -980,77 +980,8 @@
 R);%0A
-        return idWithDb.substring(idWithDb.indexOf(%22:%22) + 1).trim();%0A
     

Remove duplication of precondition checks.