1   package com.atlassian.user.configuration.util;
2   
3   import com.opensymphony.util.TextUtils;
4   import com.atlassian.user.configuration.ConfigurationException;
5   
6   import java.util.HashMap;
7   import java.util.Set;
8   
9   /**
10   * A helper class to generalize how each init(..) method reports back if it has not been configured with
11   * the correct data.
12   * <p/>
13   */
14  public class InitializationCheck
15  {
16      public static void validateArgs(HashMap dependencies, String[] requiredDependencyKeys, Object caller) throws ConfigurationException
17      {
18          Set keySet = dependencies.keySet();
19  
20          String errMessage = "";
21  
22          for (int i = 0; i < requiredDependencyKeys.length; i++)
23          {
24              String key = requiredDependencyKeys[i];
25  
26              if (!keySet.contains(key))
27              {
28                  errMessage += "Unsatisfied dependency in [" + caller.getClass().getName() + "] - missing [" + key + "]. ";
29              }
30          }
31  
32          if (TextUtils.stringSet(errMessage))
33              throw new ConfigurationException(errMessage);
34      }
35  }