Skip to content

Commit

Permalink
chore: fix generic param name naming
Browse files Browse the repository at this point in the history
  • Loading branch information
CAMOBAP committed Jul 22, 2024
1 parent e23b42b commit 2f6b108
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
/**
* A success listener class
*
* @param <TResult> expected result type
* @param <R> expected result type
*/
public interface OnSuccessListener<TResult> {
public interface OnSuccessListener<R> {

/**
* Called when the challenge is successfully completed
*
* @param result the hCaptcha token result
*/
void onSuccess(TResult result);
void onSuccess(R result);

}
28 changes: 14 additions & 14 deletions sdk/src/main/java/com/hcaptcha/sdk/tasks/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
/**
* Generic task definition which allows registration of listeners for the result/error of the task.
*
* @param <TResult> The result type of the task.
* @param <R> The result type of the task.
*/
public abstract class Task<TResult> {
public abstract class Task<R> {

private boolean complete;

private boolean successful;

private TResult result;
private R result;

private HCaptchaException hCaptchaException;

private final List<OnSuccessListener<TResult>> onSuccessListeners;
private final List<OnSuccessListener<R>> onSuccessListeners;

private final List<OnFailureListener> onFailureListeners;

Expand Down Expand Up @@ -72,7 +72,7 @@ public boolean isSuccessful() {
* @return the result object
*/
@Nullable
protected TResult getResult() {
protected R getResult() {
return result;
}

Expand All @@ -89,7 +89,7 @@ public HCaptchaException getException() {
*
* @param result the result object
*/
protected void setResult(TResult result) {
protected void setResult(R result) {
this.result = result;
this.successful = true;
this.complete = true;
Expand Down Expand Up @@ -138,7 +138,7 @@ public void run() {
* @param onSuccessListener the success listener to be triggered
* @return current object
*/
public Task<TResult> addOnSuccessListener(@NonNull final OnSuccessListener<TResult> onSuccessListener) {
public Task<R> addOnSuccessListener(@NonNull final OnSuccessListener<R> onSuccessListener) {
this.onSuccessListeners.add(onSuccessListener);
tryCb();
return this;
Expand All @@ -149,7 +149,7 @@ public Task<TResult> addOnSuccessListener(@NonNull final OnSuccessListener<TResu
* @param onSuccessListener the success listener to be removed
* @return current object
*/
public Task<TResult> removeOnSuccessListener(@NonNull final OnSuccessListener<TResult> onSuccessListener) {
public Task<R> removeOnSuccessListener(@NonNull final OnSuccessListener<R> onSuccessListener) {
if (!onSuccessListeners.remove(onSuccessListener)) {
HCaptchaLog.d("removeOnSuccessListener: %1 not found and cannot be removed", onSuccessListener);
}
Expand All @@ -162,7 +162,7 @@ public Task<TResult> removeOnSuccessListener(@NonNull final OnSuccessListener<TR
* @param onFailureListener the failure listener to be triggered
* @return current object
*/
public Task<TResult> addOnFailureListener(@NonNull final OnFailureListener onFailureListener) {
public Task<R> addOnFailureListener(@NonNull final OnFailureListener onFailureListener) {
this.onFailureListeners.add(onFailureListener);
tryCb();
return this;
Expand All @@ -173,7 +173,7 @@ public Task<TResult> addOnFailureListener(@NonNull final OnFailureListener onFai
* @param onFailureListener to be removed
* @return current object
*/
public Task<TResult> removeOnFailureListener(@NonNull final OnFailureListener onFailureListener) {
public Task<R> removeOnFailureListener(@NonNull final OnFailureListener onFailureListener) {
if (!onFailureListeners.remove(onFailureListener)) {
HCaptchaLog.d("removeOnFailureListener: %1 not found and cannot be removed", onFailureListener);
}
Expand All @@ -186,7 +186,7 @@ public Task<TResult> removeOnFailureListener(@NonNull final OnFailureListener on
* @param onOpenListener the open listener to be triggered
* @return current object
*/
public Task<TResult> addOnOpenListener(@NonNull final OnOpenListener onOpenListener) {
public Task<R> addOnOpenListener(@NonNull final OnOpenListener onOpenListener) {
this.onOpenListeners.add(onOpenListener);
tryCb();
return this;
Expand All @@ -197,7 +197,7 @@ public Task<TResult> addOnOpenListener(@NonNull final OnOpenListener onOpenListe
* @param onOpenListener to be removed
* @return current object
*/
public Task<TResult> removeOnOpenListener(@NonNull final OnOpenListener onOpenListener) {
public Task<R> removeOnOpenListener(@NonNull final OnOpenListener onOpenListener) {
if (!onOpenListeners.remove(onOpenListener)) {
HCaptchaLog.d("removeOnOpenListener: %1 not found and cannot be removed", onOpenListener);
}
Expand All @@ -208,7 +208,7 @@ public Task<TResult> removeOnOpenListener(@NonNull final OnOpenListener onOpenLi
* Remove all listeners: success, failure and open listeners
* @return current object
*/
public Task<TResult> removeAllListeners() {
public Task<R> removeAllListeners() {
onSuccessListeners.clear();
onFailureListeners.clear();
onOpenListeners.clear();
Expand All @@ -218,7 +218,7 @@ public Task<TResult> removeAllListeners() {
private void tryCb() {
boolean shouldReset = false;
if (getResult() != null) {
for (OnSuccessListener<TResult> onSuccessListener : onSuccessListeners) {
for (OnSuccessListener<R> onSuccessListener : onSuccessListeners) {
onSuccessListener.onSuccess(getResult());
shouldReset = true;
}
Expand Down

0 comments on commit 2f6b108

Please sign in to comment.