Skip to content

Instantly share code, notes, and snippets.

@jeyraof
Created July 18, 2020 07:59
Show Gist options
  • Save jeyraof/99808bdb3538a40f7a9d1b92e58b313e to your computer and use it in GitHub Desktop.
Save jeyraof/99808bdb3538a40f7a9d1b92e58b313e to your computer and use it in GitHub Desktop.
enum class Provider(val service: String) {
KAKAO("kakao"),
APPLE("apple")
}
@RestController
class TestController {
@PostMapping("/test")
fun testFunc(
@RequestParam provider: Provider,
@RequestParam(required = false) oauth_access_token: String?,
@RequestParam(required = false) authorization_code: String?
) {
val isSupportService: Boolean = when (provider) {
KAKAO -> oauth_access_token != null
APPLE -> authorization_code != null
}
if (!isSupportService) throw NotSupportedException()
}
}
@jeyraof
Copy link
Author

jeyraof commented Jul 18, 2020

if (when (provider) {
    KAKAO -> oauth_access_token == null
    APPLE -> authorization_code == null
}) throw NotSupportedException()

정도로 타협..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment