Kotlinify NoRetryPolicy (#43831)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43831

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: cortinico

Differential Revision: D55708871

fbshipit-source-id: c557743bf35cd27559fe8365025ca071bef57701
This commit is contained in:
Fabrizio Cucci
2024-04-04 12:33:18 -07:00
committed by Facebook GitHub Bot
parent 06a3028694
commit e36baddff7
2 changed files with 28 additions and 39 deletions
@@ -1,39 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.jstasks;
import com.facebook.infer.annotation.Nullsafe;
@Nullsafe(Nullsafe.Mode.LOCAL)
class NoRetryPolicy implements HeadlessJsTaskRetryPolicy {
public static final NoRetryPolicy INSTANCE = new NoRetryPolicy();
private NoRetryPolicy() {}
@Override
public boolean canRetry() {
return false;
}
@Override
public int getDelay() {
throw new IllegalStateException("Should not retrieve delay as canRetry is: " + canRetry());
}
@Override
public HeadlessJsTaskRetryPolicy update() {
throw new IllegalStateException("Should not update as canRetry is: " + canRetry());
}
@Override
public HeadlessJsTaskRetryPolicy copy() {
// Class is immutable so no need to copy
return this;
}
}
@@ -0,0 +1,28 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.jstasks
internal class NoRetryPolicy private constructor() : HeadlessJsTaskRetryPolicy {
override public fun canRetry(): Boolean = false
override public fun getDelay(): Int {
throw IllegalStateException("Should not retrieve delay as canRetry is: ${canRetry()}")
}
override public fun update(): HeadlessJsTaskRetryPolicy {
throw IllegalStateException("Should not update as canRetry is: ${canRetry()}")
}
// Class is immutable so no need to copy
override public fun copy(): HeadlessJsTaskRetryPolicy = this
public companion object {
@JvmField public val INSTANCE: NoRetryPolicy = NoRetryPolicy()
}
}