Skip to content

refactor so that any java 8 or later can use lambdas for Activate and… #175

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

Merged
merged 4 commits into from
Mar 30, 2018

Conversation

thomaszurkan-optimizely
Copy link
Contributor

… Track listeners.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 488

  • 3 of 13 (23.08%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.5%) to 88.46%

Changes Missing Coverage Covered Lines Changed/Added Lines %
core-api/src/main/java/com/optimizely/ab/notification/NotificationCenter.java 1 11 9.09%
Totals Coverage Status
Change from base Build 487: -0.5%
Covered Lines: 2154
Relevant Lines: 2435

💛 - Coveralls

@coveralls
Copy link

coveralls commented Mar 22, 2018

Pull Request Test Coverage Report for Build 495

  • 7 of 13 (53.85%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 88.789%

Changes Missing Coverage Covered Lines Changed/Added Lines %
core-api/src/main/java/com/optimizely/ab/notification/NotificationCenter.java 5 11 45.45%
Totals Coverage Status
Change from base Build 491: -0.1%
Covered Lines: 2162
Relevant Lines: 2435

💛 - Coveralls

@@ -16,9 +16,13 @@
*/
package com.optimizely.ab.notification;

import com.optimizely.ab.config.Experiment;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change the license header to say 2017-2018. Let's make sure to do this for the files we touch in the PR

/**
* Convenience method to support lambdas as callbacks in later version of Java (8+).
* @param activateNotificationListenerInterface
* @return greater than zero if added.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we will run into concurrency/threading issues with incrementing this static variable. What if we end up with the same ID for different listeners?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not static. you are looking at the holder class def and not the notification id.

@Nonnull Map<String, String> attributes,
@Nonnull Variation variation) {
}
public interface NotificationListener {

/**
* This is the new method of notification. Implementation classes such as {@link ActivateNotificationListener}
Copy link
Contributor

Choose a reason for hiding this comment

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

just a nitpick: No need to say this method is new. I think we can handle that in the changelogs


/**
* This is the new method of notification. Implementation classes such as {@link ActivateNotificationListener}
* will implement this call and provide another method with the correct parameters
* Notify called when a notification is triggered via the {@link com.optimizely.ab.notification.NotificationCenter}
* @param args - variable argument list based on the type of notification.
*/
public abstract void notify(Object... args);
public void notify(Object... args);
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of having variables args and attempting to parse them in the implementation, why not have a static notification object? I think that would be way easier to read in code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean like javascript? We only did that for javascript since it is json. The advantage to using a vararg is that you can support any kind of notify (meaning you could use it for any notification ini the system). I don't know if that is a strong enough argument. The other thing is that all other SDKs use varargs.

@wangjoshuah
Copy link
Contributor

can you try this out in a testapp to verify?

@thomaszurkan-optimizely
Copy link
Contributor Author

build

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

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

lgtm

@thomaszurkan-optimizely thomaszurkan-optimizely merged commit 00c2312 into master Mar 30, 2018
@thomaszurkan-optimizely thomaszurkan-optimizely deleted the refactor/notification/forLambda branch March 30, 2018 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants