-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev/1.21' into dev/1.21-networking
- Loading branch information
Showing
4 changed files
with
89 additions
and
20 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
base/common/src/main/java/band/kessoku/lib/api/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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package band.kessoku.lib.api.base.reflect; | ||
|
||
import java.lang.reflect.Member; | ||
import java.lang.reflect.Modifier; | ||
|
||
public final class ModifiersUtil { | ||
private ModifiersUtil() { | ||
} | ||
|
||
/* === Common === */ | ||
|
||
public static boolean isPublic(Member field) { | ||
return Modifier.isPublic(field.getModifiers()); | ||
} | ||
|
||
public static boolean isStatic(Member field) { | ||
return Modifier.isStatic(field.getModifiers()); | ||
} | ||
|
||
/* === Common Combo === */ | ||
|
||
public static boolean isPublicAndStatic(Member field) { | ||
return isPublic(field) && isStatic(field); | ||
} | ||
|
||
public static boolean isPublicOrStatic(Member field, boolean shouldPublic, boolean shouldStatic) { | ||
return shouldPublic == isPublic(field) && shouldStatic == isStatic(field); | ||
} | ||
|
||
/* === Common End === */ | ||
|
||
/* === Data Object === */ | ||
|
||
public static boolean isVolatile(Member field) { | ||
return Modifier.isVolatile(field.getModifiers()); | ||
} | ||
|
||
public static boolean isTransient(Member field) { | ||
return Modifier.isTransient(field.getModifiers()); | ||
} | ||
|
||
/* === Data Object End === */ | ||
|
||
/* === Low Usage Tools === */ | ||
|
||
public static boolean isFinal(Member field) { | ||
return Modifier.isFinal(field.getModifiers()); | ||
} | ||
|
||
public static boolean isProtected(Member field) { | ||
return Modifier.isProtected(field.getModifiers()); | ||
} | ||
|
||
/* === Low Usage Tools End === */ | ||
} |
14 changes: 14 additions & 0 deletions
14
base/common/src/main/java/band/kessoku/lib/api/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package band.kessoku.lib.api.base.reflect; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Arrays; | ||
|
||
public final class ReflectUtil { | ||
private ReflectUtil() { | ||
} | ||
|
||
public static boolean isAssignableFrom(Field field, Class<?>... clazzs) { | ||
var flag = Arrays.stream(clazzs).anyMatch(clazz -> !field.getType().isAssignableFrom(clazz)); | ||
return !flag; | ||
} | ||
} |
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
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