Skip to content

Instantly share code, notes, and snippets.

@ferPrieto
Created June 30, 2020 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferPrieto/614f2d1ed8b2b7b50746fc1a6021a3fa to your computer and use it in GitHub Desktop.
Save ferPrieto/614f2d1ed8b2b7b50746fc1a6021a3fa to your computer and use it in GitHub Desktop.
internal class InstagramTypeFactory : DefaultTypeFactory() {
override fun KParameter.createArgument(): Any? =
when (type.classifier) {
Int::class -> 0
Byte::class -> 0.toByte()
Short::class -> 0.toShort()
String::class -> ""
Float::class -> 0f
Long::class -> 0L
List::class -> emptyList<String>()
else -> if ((type.classifier as KClass<out Any>).findAnnotation<InstagramErrorCode>() != null) ErrorCode.TimeOut else null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment