/**
 * Copyright (c) Anton Johansson <antoon.johansson@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.antonjohansson.geolocation;

import static java.util.stream.Collectors.groupingBy;

import java.util.List;
import java.util.Map;

import com.antonjohansson.geolocation.config.Configuration;
import com.antonjohansson.geolocation.framework.Provider;
import com.antonjohansson.geolocation.framework.Source;
import com.antonjohansson.geolocation.framework.domain.LookupResult;
import com.antonjohansson.geolocation.framework.domain.SourceData;

/**
 * Contains the main entry-point of the application.
 */
public class EntryPoint
{
    /**
     * The main entry-point of the application.
     */
    public static void main(String[] args)
    {
        if (args.length < 1)
        {
            throw new RuntimeException("Must contain an argument for the configuration file");
        }

        String configurationFile = args[0];
        Configuration configuration = new Configuration(configurationFile);
        configuration.load();

        Provider provider = configuration.getProvider();
        Source<? extends SourceData> source = configuration.getSource();

        provider.validate(configuration);
        handle(configuration, provider, source);
    }

    private static <T extends SourceData> void handle(Configuration configuration, Provider provider, Source<T> source)
    {
        List<T> items = source.getData(configuration.getBatchSize());
        if (items.size() > configuration.getBatchSize())
        {
            throw new RuntimeException("Source returned more data than expected");
        }
        if (items.isEmpty())
        {
            System.out.println("There is nothing to provide coordinates for, exiting...");
            return;
        }

        Map<String, List<T>> map = items.stream().collect(groupingBy(SourceData::getAddress));
        List<LookupResult> results = provider.lookup(map.keySet());
        for (LookupResult result : results)
        {
            String ip = result.getIp();
            for (T item : map.get(ip))
            {
                source.update(item, result.getLongitude(), result.getLatitude());
            }
        }
    }
}

@@ -1202,69 +1202,52 @@
     
-/**%0D%0A     * The main entry-point of the applic
+private final Configuration configur
 ation
-.
+;
 %0D%0A
-     */
 %0D%0A  
@@ -1259,162 +1259,95 @@
 lic 
-static void main(String%5B%5D args)%0D%0A    %7B%0D%0A        if (args.length %3C 1)%0D%0A        %7B%0D%0A            throw new RuntimeException(%22Must contain an argument for the 
+EntryPoint(String configurationFile)%0D%0A    %7B%0D%0A        configuration = new Configuration(
 conf
@@ -1359,22 +1359,20 @@
 tion
- f
+F
 ile
-%22
 );%0D%0A    
     
@@ -1371,137 +1371,89 @@
     
+%7D%0D%0A%0D%0A
     
-%7D%0D%0A
+/**
 %0D%0A     
-   String configurationFile = args%5B0%5D;%0D%0A        Configuration configuration = new Configuration(configurationFile);
+* Runs the application.%0D%0A     */%0D%0A    public void run()%0D%0A    %7B
 %0D%0A  
@@ -1675,31 +1675,16 @@
  handle(
-configuration, 
 provider
@@ -1712,87 +1712,468 @@
     
-private static %3CT extends SourceData%3E void handle(Configuration configuration, 
+/**%0D%0A     * The main entry-point of the application.%0D%0A     */%0D%0A    public static void main(String%5B%5D args)%0D%0A    %7B%0D%0A        if (args.length %3C 1)%0D%0A        %7B%0D%0A            throw new RuntimeException(%22Must contain an argument for the configuration file%22);%0D%0A        %7D%0D%0A%0D%0A        String configurationFile = args%5B0%5D;%0D%0A        EntryPoint entryPoint = new EntryPoint(configurationFile);%0D%0A        entryPoint.run();%0D%0A    %7D%0D%0A%0D%0A    private %3CT extends SourceData%3E void handle(
 Prov

Tweak entry point to reduce statics