Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding annotations on public APIs #83

Merged
merged 4 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ class CustomIdentityFragment : Fragment() {
val isPrimary: Boolean = sharedViewModel.isPrimary.value ?: false

val item = IdentityItem(identifier, authenticatedState, isPrimary)
Identity.removeIdentity(item, namespace)
if (namespace != null) {
Identity.removeIdentity(item, namespace)
}
}

// Advertising identifier features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,23 @@ public void testGetExtensionVersionAPI() {
@Test
public void testRegisterExtensionAPI() throws InterruptedException {
// test
// Identity.registerExtension() is called in the setup method
//noinspection deprecation
Identity.registerExtension();
emdobrin marked this conversation as resolved.
Show resolved Hide resolved

// verify that the extension is registered with the correct version details
Map<String, String> sharedStateMap = flattenMap(
getSharedStateFor(IdentityTestConstants.SharedStateName.EVENT_HUB, 5000)
);
assertEquals(
IdentityConstants.EXTENSION_VERSION,
sharedStateMap.get("extensions.com.adobe.edge.identity.version")
);
}

@Test
public void testRegisterExtension_withClass() throws InterruptedException {
// test
// MobileCore.registerExtensions with Identity is called in the setup method

// verify that the extension is registered with the correct version details
Map<String, String> sharedStateMap = flattenMap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@

import static com.adobe.marketing.mobile.edge.identity.IdentityConstants.LOG_TAG;

import androidx.annotation.NonNull;
import com.adobe.marketing.mobile.AdobeCallback;
import com.adobe.marketing.mobile.AdobeCallbackWithError;
import com.adobe.marketing.mobile.AdobeError;
import com.adobe.marketing.mobile.Event;
import com.adobe.marketing.mobile.EventSource;
import com.adobe.marketing.mobile.EventType;
import com.adobe.marketing.mobile.Extension;
import com.adobe.marketing.mobile.ExtensionError;
import com.adobe.marketing.mobile.ExtensionErrorCallback;
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.services.Log;
import com.adobe.marketing.mobile.util.DataReader;
Expand All @@ -47,29 +46,27 @@ private Identity() {}
*
* @return The version as {@code String}
*/
@NonNull
public static String extensionVersion() {
return IdentityConstants.EXTENSION_VERSION;
}

/**
* Registers the extension with the Mobile SDK. This method should be called only once in your application class.
*
* @deprecated Use {@link MobileCore#registerExtensions(List, AdobeCallback)} with {@link Identity#EXTENSION} instead.
* @deprecated as of 2.0.0, use {@link MobileCore#registerExtensions(List, AdobeCallback)} with {@link Identity#EXTENSION} instead.
*/
@Deprecated
@SuppressWarnings("deprecation")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we suppressing warnings here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it shows a warning in the IDE when using the registerExtension API so it suppresses that, but you would still see the deprecation message on the API itself

public static void registerExtension() {
MobileCore.registerExtension(
IdentityExtension.class,
new ExtensionErrorCallback<ExtensionError>() {
@Override
public void error(ExtensionError extensionError) {
Log.error(
LOG_TAG,
LOG_SOURCE,
"There was an error registering the Edge Identity extension: " + extensionError.getErrorName()
);
}
}
extensionError ->
Log.error(
LOG_TAG,
LOG_SOURCE,
"There was an error registering the Edge Identity extension: " + extensionError.getErrorName()
)
);
}

Expand All @@ -80,7 +77,7 @@ public void error(ExtensionError extensionError) {
* If an {@link AdobeCallbackWithError} is provided, an {@link AdobeError} can be returned in the
* eventuality of any error that occurred while getting the Experience Cloud ID
*/
public static void getExperienceCloudId(final AdobeCallback<String> callback) {
public static void getExperienceCloudId(@NonNull final AdobeCallback<String> callback) {
if (callback == null) {
Log.debug(LOG_TAG, LOG_SOURCE, "Unexpected null callback, provide a callback to retrieve current ECID.");
return;
Expand All @@ -95,7 +92,7 @@ public static void getExperienceCloudId(final AdobeCallback<String> callback) {

final AdobeCallbackWithError<Event> callbackWithError = new AdobeCallbackWithError<Event>() {
@Override
public void call(Event responseEvent) {
public void call(final Event responseEvent) {
if (responseEvent == null || responseEvent.getEventData() == null) {
returnError(callback, AdobeError.UNEXPECTED_ERROR);
return;
Expand Down Expand Up @@ -125,7 +122,7 @@ public void call(Event responseEvent) {
}

@Override
public void fail(AdobeError adobeError) {
public void fail(final AdobeError adobeError) {
returnError(callback, adobeError);
Log.debug(
LOG_TAG,
Expand Down Expand Up @@ -159,7 +156,7 @@ public void fail(AdobeError adobeError) {
* If an {@link AdobeCallbackWithError} is provided, an {@link AdobeError} can be returned in the
* eventuality of any error that occurred while getting the identifiers query string
*/
public static void getUrlVariables(final AdobeCallback<String> callback) {
public static void getUrlVariables(@NonNull final AdobeCallback<String> callback) {
if (callback == null) {
Log.debug(
LOG_TAG,
Expand Down Expand Up @@ -231,7 +228,7 @@ public void fail(final AdobeError adobeError) {
*
* @param identityMap The identifiers to add or update.
*/
public static void updateIdentities(final IdentityMap identityMap) {
public static void updateIdentities(@NonNull final IdentityMap identityMap) {
if (identityMap == null || identityMap.isEmpty()) {
Log.debug(LOG_TAG, LOG_SOURCE, "Unable to updateIdentities, IdentityMap is null or empty");
return;
Expand All @@ -255,7 +252,7 @@ public static void updateIdentities(final IdentityMap identityMap) {
* @param item the {@link IdentityItem} to remove.
* @param namespace The namespace of the identity to remove.
*/
public static void removeIdentity(final IdentityItem item, final String namespace) {
public static void removeIdentity(@NonNull final IdentityItem item, @NonNull final String namespace) {
if (StringUtils.isNullOrEmpty(namespace)) {
Log.debug(LOG_TAG, LOG_SOURCE, "Unable to removeIdentity, namespace is null or empty");
return;
Expand Down Expand Up @@ -286,7 +283,7 @@ public static void removeIdentity(final IdentityItem item, final String namespac
* If an {@link AdobeCallbackWithError} is provided, an {@link AdobeError} can be returned in the
* eventuality of any error that occurred while getting the stored identities.
*/
public static void getIdentities(final AdobeCallback<IdentityMap> callback) {
public static void getIdentities(@NonNull final AdobeCallback<IdentityMap> callback) {
if (callback == null) {
Log.debug(
LOG_TAG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ protected String getName() {
return IdentityConstants.EXTENSION_NAME;
}

@NonNull
@Override
protected String getFriendlyName() {
return IdentityConstants.EXTENSION_FRIENDLY_NAME;
}

@NonNull
@Override
protected String getVersion() {
return IdentityConstants.EXTENSION_VERSION;
Expand Down