package fi.vincit.multiusertest.util;

import fi.vincit.multiusertest.annotation.TestUsers;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class AnnotationUtil {

    public static Set<UserIdentifier> getUsers(TestUsers testUsers) {
        if (testUsers != null) {
            Set<UserIdentifier> userIdentifiers = new HashSet<>();
            for (String user : testUsers.users()) {
                userIdentifiers.add(UserIdentifier.parse(user));
            }
            return userIdentifiers;
        } else {
            return Collections.emptySet();
        }
    }

    public static Set<UserIdentifier> getCreators(TestUsers testUsers) {
        if (testUsers != null) {
            Set<UserIdentifier> userIdentifiers = new HashSet<>();
            for (String user : testUsers.creators()) {
                userIdentifiers.add(UserIdentifier.parse(user));
            }
            return userIdentifiers;
        } else {
            return Collections.emptySet();
        }
    }

}

@@ -327,115 +327,111 @@
     
-Set%3CUserIdentifier%3E userIdentifiers = new HashSet%3C%3E();%0D%0A            for (String user : testUsers.users()) %7B
+return getDefinitions(testUsers.users());%0D%0A        %7D else %7B%0D%0A            return Collections.emptySet();
 %0D%0A  
@@ -440,115 +440,183 @@
     
+%7D%0D%0A
     
-    userIdentifiers.add(UserIdentifier.parse(user));%0D%0A            %7D%0D%0A            return userIdentifiers
+%7D%0D%0A%0D%0A    public static Set%3CUserIdentifier%3E getCreators(TestUsers testUsers) %7B%0D%0A        if (testUsers != null) %7B%0D%0A            return getDefinitions(testUsers.creators())
 ;%0D%0A 
@@ -693,37 +693,38 @@
 %0D%0A    %7D%0D%0A%0D%0A    p
-ublic
+rivate
  static Set%3CUser
@@ -742,79 +742,45 @@
  get
-Creators(TestUsers testUsers) %7B%0D%0A        if (testUsers != null
+Definitions(String%5B%5D definitions
 ) %7B%0D%0A
-    
     
@@ -847,20 +847,16 @@
         
-    
 for (Str
@@ -866,36 +866,27 @@
  user : 
-testUsers.creators()
+definitions
 ) %7B%0D%0A   
@@ -894,20 +894,16 @@
         
-    
 userIden
@@ -952,27 +952,19 @@
         
-    %7D%0D%0A    
+%7D%0D%0A
         
@@ -992,81 +992,8 @@
 s;%0D%0A
-        %7D else %7B%0D%0A            return Collections.emptySet();%0D%0A        %7D%0D%0A
     

Refactor AnnotationUtil