Skip to content

Commit

Permalink
feat(bufferapi): remove nullable in fromBufferType
Browse files Browse the repository at this point in the history
We should take advantage of compilers to
get compile time errors when a new value isn't handled
instead of using default.
  • Loading branch information
123mpozzi committed Oct 25, 2023
1 parent 539e8e8 commit 6f38a5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1208,13 +1208,12 @@ class JsonConverter {
/**
* Converts any [BufferType] value into its json representation.
* @param bufferType [BufferType] value.
* @return The produced JS string, or `null` if not recognized.
* @return The produced JS string.
*/
@JvmStatic
fun fromBufferType(bufferType: BufferType?): String? = when (bufferType) {
fun fromBufferType(bufferType: BufferType): String = when (bufferType) {
BufferType.ForwardDuration -> "forwardDuration"
BufferType.BackwardDuration -> "backwardDuration"
else -> null
}

@JvmStatic
Expand Down
6 changes: 2 additions & 4 deletions ios/RCTConvert+BitmovinPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1190,16 +1190,14 @@ extension RCTConvert {
/**
* Converts any `BufferType` value into its json representation.
* - Parameter bufferType: `BufferType` value.
* - Returns: The produced JS string, or `nil` if not recognized.
* - Returns: The produced JS string.
*/
static func toJson(bufferType: BufferType) -> String? {
static func toJson(bufferType: BufferType) -> String {
switch bufferType {
case .forwardDuration:
return "forwardDuration"
case .backwardDuration:
return "backwardDuration"
default:
return nil
}
}

Expand Down

0 comments on commit 6f38a5b

Please sign in to comment.