Permalink
Browse files

Add 12 failing tests for the intended new behavior

  • Loading branch information...
Zhuinden committed Sep 9, 2018
1 parent 379f78c commit 245f00dc118a1c8274823146031b3bbb9af4d701
@@ -454,6 +454,17 @@ public boolean hasService(@NonNull ScopeKey scopeKey, @NonNull String serviceTag
return getManager().hasService(scopeKey, serviceTag);
}
/**
* Returns if a service is bound to the scope identified by the provided tag.
*
* @param scopeTag the tag of the scope
* @param serviceTag the service tag
* @return whether the service is bound in the given scope
*/
public boolean hasService(@NonNull String scopeTag, @NonNull String serviceTag) {
return getManager().hasService(scopeTag, serviceTag);
}
/**
* Returns the service bound to the scope of the {@link ScopeKey} by the provided tag.
*
@@ -467,6 +478,19 @@ public boolean hasService(@NonNull ScopeKey scopeKey, @NonNull String serviceTag
return getManager().getService(scopeKey, serviceTag);
}
/**
* Returns the service bound to the scope identified by the provided tag.
*
* @param scopeTag the tag of the scope
* @param serviceTag the service tag
* @param <T> the type of the service
* @return the service
*/
@NonNull
public <T> T getService(@NonNull String scopeTag, @NonNull String serviceTag) {
return getManager().getService(scopeTag, serviceTag);
}
/**
* Attempts to look-up the service in all currently existing scopes, starting from the last added scope.
* Returns whether the service exists in any scopes.
@@ -2,10 +2,38 @@
import android.support.annotation.NonNull;
import java.util.List;
/**
* Inheriting from {@link ScopeKey} allows defining that our key belongs to a given scope, that a scope is associated with it.
*/
public interface ScopeKey {
/**
* Defines the tag of the scope this key defines the existence of.
*
* @return the tag of the scope
*/
@NonNull
String getScopeTag();
/**
* Inheriting from {@link Child} enables defining an explicit parent hierarchy, thus ensuring that
* even if the scopes are not defined by the tags of any existing keys in the {@link Backstack}'s current {@link History},
* the scopes will still be created, bound and shall exist.
*
* During {@link BackstackManager#lookupService(String)}, the explicit parents are traversed first, and implicit parents second. Implicit scope inheritance means that the previous keys' scopes will be traversed as well.
*
* If a {@link Child} is the top-most scope, then its explicit scopes are activated as well, so their services have {@link com.zhuinden.simplestack.ScopedServices.Activated#onScopeActive(String)} called if they implement {@link com.zhuinden.simplestack.ScopedServices.Activated}.
*/
public interface Child {
/**
* Defines the hierarchy of the parent scope that ought to exist as explicit parents of this key.
*
* The order of the items matters: the top-most scope is the first, the bottom-most parent is the last.
*
* @return the list of scope tags that ought to serve as the key's hierarchy of explicit parents
*/
@NonNull
List<String> getParentScopes();
}
}
@@ -304,6 +304,17 @@ public static boolean hasService(@NonNull Context context, @NonNull ScopeKey sco
return getManager(context).hasService(scopeKey, serviceTag);
}
/**
* Returns if a service is bound to the scope identified by the provided tag.
*
* @param scopeTag the scope tag
* @param serviceTag the service tag
* @return whether the service is bound in the given scope
*/
public static boolean hasService(@NonNull Context context, @NonNull String scopeTag, @NonNull String serviceTag) {
return getManager(context).hasService(scopeTag, serviceTag);
}
/**
* Returns the service bound to the scope of the {@link ScopeKey} by the provided tag.
*
@@ -317,6 +328,19 @@ public static boolean hasService(@NonNull Context context, @NonNull ScopeKey sco
return getManager(context).getService(scopeKey, serviceTag);
}
/**
* Returns the service bound to the scope identified by the provided tag.
*
* @param scopeTag the scope tag
* @param serviceTag the service tag
* @param <T> the type of the service
* @return the service
*/
@NonNull
public static <T> T getService(@NonNull Context context, @NonNull String scopeTag, @NonNull String serviceTag) {
return getManager(context).getService(scopeTag, serviceTag);
}
/**
* Attempts to look-up the service in all currently existing scopes, starting from the last added scope.
* Returns whether the service exists in any scopes.
Oops, something went wrong.

0 comments on commit 245f00d

Please sign in to comment.