class EmrDaoImpl implements EmrDao {

    protected List<InstanceGroupConfig> getInstanceGroupConfigs(InstanceDefinitions instanceDefinitions)
    {
        List<InstanceGroupConfig> instanceGroupConfigs = null;

        if (!emrHelper.isInstanceDefinitionsEmpty(instanceDefinitions))
        {
            // Create the instance group configurations.
            instanceGroupConfigs = new ArrayList<>();

            // Fill-in the MASTER node details.
            instanceGroupConfigs.add(getInstanceGroupConfig(InstanceRoleType.MASTER, instanceDefinitions.getMasterInstances().getInstanceType(),
                instanceDefinitions.getMasterInstances().getInstanceCount(), instanceDefinitions.getMasterInstances().getInstanceSpotPrice(),
                instanceDefinitions.getMasterInstances().getEbsConfiguration()));

            // if the optional core instances are specified, fill-in the CORE node details.
            if (instanceDefinitions.getCoreInstances() != null)
            {
                instanceGroupConfigs.add(getInstanceGroupConfig(InstanceRoleType.CORE, instanceDefinitions.getCoreInstances().getInstanceType(),
                    instanceDefinitions.getCoreInstances().getInstanceCount(), instanceDefinitions.getCoreInstances().getInstanceSpotPrice(),
                    instanceDefinitions.getCoreInstances().getEbsConfiguration()));
            }

            // If the optional task instances are specified, fill-in the TASK node details.
            if (instanceDefinitions.getTaskInstances() != null)
            {
                instanceGroupConfigs.add(getInstanceGroupConfig(InstanceRoleType.TASK, instanceDefinitions.getTaskInstances().getInstanceType(),
                    instanceDefinitions.getTaskInstances().getInstanceCount(), instanceDefinitions.getTaskInstances().getInstanceSpotPrice(),
                    instanceDefinitions.getTaskInstances().getEbsConfiguration()));
            }
        }

        return instanceGroupConfigs;
    }

}