// Path: flow/src/main/java/flow/Services.java
// public class Services {
//   static final Services ROOT_SERVICES =
//       new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap());
// 
//   public static final class Binder extends Services {
//     private final Map<String, Object> services = new LinkedHashMap<>();
//     private final Services base;
// 
//     private Binder(Services base, Object key) {
//       super(key, base, Collections.<String, Object>emptyMap());
//       checkNotNull(base, "only root Services should have a null base");
//       this.base = base;
//     }
// 
//     @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) {
//       services.put(serviceName, service);
//       return this;
//     }
// 
//     @NonNull Services build() {
//       return new Services(getKey(), base, services);
//     }
//   }
// 
//   private final Object key;
//   @Nullable private final Services delegate;
//   private final Map<String, Object> localServices = new LinkedHashMap<>();
// 
//   private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) {
//     this.delegate = delegate;
//     this.key = key;
//     this.localServices.putAll(localServices);
//   }
// 
//   @Nullable public <T> T getService(@NonNull String name) {
//     if (localServices.containsKey(name)) {
//       @SuppressWarnings("unchecked") //
//       final T service = (T) localServices.get(name);
//       return service;
//     }
//     if (delegate != null) return delegate.getService(name);
//     return null;
//   }
// 
//   @NonNull public <T> T getKey() {
//     //noinspection unchecked
//     return (T) this.key;
//   }
// 
//   @NonNull Binder extend(@NonNull Object key) {
//     return new Binder(this, key);
//   }
// }
// 
// Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/ContactsUIKey.java
// public class ContactsUIKey extends ClassKey {
// }
// 
// Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java
// public final class EditContactKey extends ContactKey implements TreeKey {
// 
//     public EditContactKey(Contact contact) {
//         super(contact);
//     }
// 
//     @NonNull
//     @Override
//     public Object getParentKey() {
//         return new ContactsUIKey();
//     }
// }
// 
// Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java
// public class ScreenScoper {
// 
//     public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) {
// 
//         parentScope = parentScope.findChild(RootActivity.class.getName());
//         MortarScope childScope = parentScope.findChild(name);
// 
//         if (childScope != null)
//             return childScope;
// 
//         if (!(key instanceof InjectionComponent)) {
//             //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName()));
//             return null;
//         }
// 
//         InjectionComponent screenComponent = (InjectionComponent) key;
//         Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME));
// 
//         return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name);
//     }
// 
// }


import android.util.Log;
import flow.Services;
import flow.ServicesFactory;
import leonardo2204.com.br.flowtests.flow.keys.ContactsUIKey;
import leonardo2204.com.br.flowtests.flow.keys.EditContactKey;
import leonardo2204.com.br.flowtests.mortar.ScreenScoper;
import mortar.MortarScope;
package leonardo2204.com.br.flowtests.flow.serviceFactory;



/**
 * Created by Leonardo on 04/03/2016.
 */
public class DaggerServiceFactory extends ServicesFactory {

    private final MortarScope parentScope;
// Path: flow/src/main/java/flow/Services.java
// public class Services {
//   static final Services ROOT_SERVICES =
//       new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap());
// 
//   public static final class Binder extends Services {
//     private final Map<String, Object> services = new LinkedHashMap<>();
//     private final Services base;
// 
//     private Binder(Services base, Object key) {
//       super(key, base, Collections.<String, Object>emptyMap());
//       checkNotNull(base, "only root Services should have a null base");
//       this.base = base;
//     }
// 
//     @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) {
//       services.put(serviceName, service);
//       return this;
//     }
// 
//     @NonNull Services build() {
//       return new Services(getKey(), base, services);
//     }
//   }
// 
//   private final Object key;
//   @Nullable private final Services delegate;
//   private final Map<String, Object> localServices = new LinkedHashMap<>();
// 
//   private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) {
//     this.delegate = delegate;
//     this.key = key;
//     this.localServices.putAll(localServices);
//   }
// 
//   @Nullable public <T> T getService(@NonNull String name) {
//     if (localServices.containsKey(name)) {
//       @SuppressWarnings("unchecked") //
//       final T service = (T) localServices.get(name);
//       return service;
//     }
//     if (delegate != null) return delegate.getService(name);
//     return null;
//   }
// 
//   @NonNull public <T> T getKey() {
//     //noinspection unchecked
//     return (T) this.key;
//   }
// 
//   @NonNull Binder extend(@NonNull Object key) {
//     return new Binder(this, key);
//   }
// }
// 
// Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/ContactsUIKey.java
// public class ContactsUIKey extends ClassKey {
// }
// 
// Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java
// public final class EditContactKey extends ContactKey implements TreeKey {
// 
//     public EditContactKey(Contact contact) {
//         super(contact);
//     }
// 
//     @NonNull
//     @Override
//     public Object getParentKey() {
//         return new ContactsUIKey();
//     }
// }
// 
// Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java
// public class ScreenScoper {
// 
//     public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) {
// 
//         parentScope = parentScope.findChild(RootActivity.class.getName());
//         MortarScope childScope = parentScope.findChild(name);
// 
//         if (childScope != null)
//             return childScope;
// 
//         if (!(key instanceof InjectionComponent)) {
//             //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName()));
//             return null;
//         }
// 
//         InjectionComponent screenComponent = (InjectionComponent) key;
//         Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME));
// 
//         return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name);
//     }
// 
// }


// Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/DaggerServiceFactory.java
import android.util.Log;
import flow.Services;
import flow.ServicesFactory;
import leonardo2204.com.br.flowtests.flow.keys.ContactsUIKey;
import leonardo2204.com.br.flowtests.flow.keys.EditContactKey;
import leonardo2204.com.br.flowtests.mortar.ScreenScoper;
import mortar.MortarScope;

package leonardo2204.com.br.flowtests.flow.serviceFactory;



/**
 * Created by Leonardo on 04/03/2016.
 */
public class DaggerServiceFactory extends ServicesFactory {

    private final MortarScope parentScope;
    private final ScreenScoper screenScoper;