-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat kotlin's
kotlin.Deprecated
as a deprecated operation
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
modules/swagger-core/src/main/java/io/swagger/v3/core/util/KotlinDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.swagger.v3.core.util; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
public class KotlinDetector { | ||
private static final Boolean kotlinAvailable; | ||
private static final Class<? extends Annotation> kotlinDeprecated; | ||
|
||
static { | ||
kotlinAvailable = loadByClassOrNull("kotlin.Metadata") != null; | ||
kotlinDeprecated = loadByClassOrNull("kotlin.Deprecated"); | ||
} | ||
|
||
private static <T> Class<T> loadByClassOrNull(String className) { | ||
try { | ||
return (Class<T>) ReflectionUtils.loadClassByName(className); | ||
} catch (ClassNotFoundException ex) { | ||
return null; | ||
} | ||
} | ||
|
||
public static boolean isKotlinPresent() { | ||
return kotlinAvailable; | ||
} | ||
|
||
public static Class<? extends Annotation> getKotlinDeprecated() { | ||
return kotlinDeprecated; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters