-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f97c73
commit e8c788e
Showing
2 changed files
with
13 additions
and
52 deletions.
There are no files selected for viewing
53 changes: 11 additions & 42 deletions
53
base/common/src/main/java/band/kessoku/lib/base/reflect/ModifiersUtil.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 |
---|---|---|
@@ -1,86 +1,55 @@ | ||
package band.kessoku.lib.base.reflect; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Method; | ||
import java.lang.reflect.Member; | ||
import java.lang.reflect.Modifier; | ||
|
||
public final class ModifiersUtil { | ||
private ModifiersUtil() { | ||
} | ||
|
||
/* === Common === */ | ||
|
||
public static boolean isPublic(Field field) { | ||
public static boolean isPublic(Member field) { | ||
return Modifier.isPublic(field.getModifiers()); | ||
} | ||
|
||
public static boolean isPublic(Method method) { | ||
return Modifier.isPublic(method.getModifiers()); | ||
} | ||
|
||
public static boolean isStatic(Field field) { | ||
public static boolean isStatic(Member field) { | ||
return Modifier.isStatic(field.getModifiers()); | ||
} | ||
|
||
public static boolean isStatic(Method method) { | ||
return Modifier.isStatic(method.getModifiers()); | ||
} | ||
|
||
/* === Common Combo === */ | ||
|
||
public static boolean isPublicAndStatic(Field field) { | ||
public static boolean isPublicAndStatic(Member field) { | ||
return isPublic(field) && isStatic(field); | ||
} | ||
|
||
public static boolean isPublicAndStatic(Method method) { | ||
return isPublic(method) && isStatic(method); | ||
} | ||
|
||
public static boolean isPublicOrStatic(Field field, boolean shouldPublic, boolean shouldStatic) { | ||
public static boolean isPublicOrStatic(Member field, boolean shouldPublic, boolean shouldStatic) { | ||
return shouldPublic == isPublic(field) && shouldStatic == isStatic(field); | ||
} | ||
|
||
public static boolean isPublicOrStatic(Method method, boolean shouldPublic, boolean shouldStatic) { | ||
return shouldPublic == isPublic(method) && shouldStatic == isStatic(method); | ||
} | ||
|
||
/* === Common End === */ | ||
|
||
/* === Data Object === */ | ||
|
||
public static boolean isVolatile(Field field) { | ||
public static boolean isVolatile(Member field) { | ||
return Modifier.isVolatile(field.getModifiers()); | ||
} | ||
|
||
public static boolean isVolatile(Method method) { | ||
return Modifier.isVolatile(method.getModifiers()); | ||
} | ||
|
||
public static boolean isTransient(Field field) { | ||
public static boolean isTransient(Member field) { | ||
return Modifier.isTransient(field.getModifiers()); | ||
} | ||
|
||
public static boolean isTransient(Method method) { | ||
return Modifier.isTransient(method.getModifiers()); | ||
} | ||
|
||
/* === Data Object End === */ | ||
|
||
/* === Low Usage Tools === */ | ||
|
||
public static boolean isFinal(Field field) { | ||
public static boolean isFinal(Member field) { | ||
return Modifier.isFinal(field.getModifiers()); | ||
} | ||
|
||
public static boolean isFinal(Method method) { | ||
return Modifier.isFinal(method.getModifiers()); | ||
} | ||
|
||
public static boolean isProtected(Field field) { | ||
public static boolean isProtected(Member field) { | ||
return Modifier.isProtected(field.getModifiers()); | ||
} | ||
|
||
public static boolean isProtected(Method method) { | ||
return Modifier.isProtected(method.getModifiers()); | ||
} | ||
|
||
/* === Low Usage Tools End === */ | ||
} |
12 changes: 2 additions & 10 deletions
12
base/common/src/main/java/band/kessoku/lib/base/reflect/ReflectUtil.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