package willitconnect.controller.service.util;

import org.apache.log4j.Logger;
import org.json.JSONObject;
import willitconnect.controller.model.CheckedEntry;

import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.function.Consumer;

import static willitconnect.controller.service.HostMatcher.isHost;


public class EntryConsumer implements Consumer<String> {
    private Logger log = Logger.getLogger(EntryConsumer.class);

    private final JSONObject vcapServices;
    private final List<CheckedEntry> entries;

    public EntryConsumer(List<CheckedEntry> entries, JSONObject vcapServices) {
        this.entries = entries;
        this.vcapServices = vcapServices;
    }

    @Override
    public void accept(String key) {
        log.info("Cheking " + key);
        if (!isHost(key)) {
            //Check over any sub json objects.
            JSONObject possibleObject = vcapServices.optJSONObject(key);
            if ( null != possibleObject ) {
                possibleObject.keys().forEachRemaining(
                        new EntryConsumer(entries, possibleObject));
            }
        };

        CheckedEntry entry = new CheckedEntry(Date.from(Instant.now()),
                vcapServices.optString(key), false);

        entries.add(entry);
    }
}

@@ -45,40 +45,8 @@
 l;%0A%0A
-import org.apache.log4j.Logger;%0A
 impo
@@ -69,16 +69,16 @@
 Object;%0A
+
 import w
@@ -360,73 +360,8 @@
 %3E %7B%0A
-    private Logger log = Logger.getLogger(EntryConsumer.class);%0A%0A
     
@@ -621,16 +621,16 @@
 verride%0A
+
     publ
@@ -662,44 +662,8 @@
 ) %7B%0A
-        log.info(%22Cheking %22 + key);%0A
     

Remove overly verbose logging