mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
committed by
Facebook GitHub Bot
parent
06a3028694
commit
e36baddff7
-39
@@ -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;
|
||||
}
|
||||
}
|
||||
+28
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user