下面列出了java.lang.reflect.Modifier#isStrict ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public <T extends LineAppender<T>> void joinTo(T appender, Preference preference) throws IOException {
if (Modifier.isPublic(modifier)) appender.append("public ");
if (Modifier.isProtected(modifier)) appender.append("protected ");
if (Modifier.isPrivate(modifier)) appender.append("private ");
if (Modifier.isAbstract(modifier)) appender.append("abstract ");
if (Modifier.isStatic(modifier)) appender.append("static ");
if (Modifier.isFinal(modifier)) appender.append("final ");
if (Modifier.isInterface(modifier)) appender.append("interface ");
if (Modifier.isVolatile(modifier)) appender.append("volatile ");
if (Modifier.isNative(modifier)) appender.append("native ");
if (Modifier.isStrict(modifier)) appender.append("strict ");
if (Modifier.isSynchronized(modifier)) appender.append("synchronized ");
if (Modifier.isTransient(modifier)) appender.append("transient ");
}
@Override
public <T extends LineAppender<T>> void joinTo(T appender, Preference preference) throws IOException {
if (Modifier.isPublic(modifier)) appender.append("public ");
if (Modifier.isProtected(modifier)) appender.append("protected ");
if (Modifier.isPrivate(modifier)) appender.append("private ");
if (Modifier.isAbstract(modifier)) appender.append("abstract ");
if (Modifier.isStatic(modifier)) appender.append("static ");
if (Modifier.isFinal(modifier)) appender.append("final ");
if (Modifier.isInterface(modifier)) appender.append("interface ");
if (Modifier.isVolatile(modifier)) appender.append("volatile ");
if (Modifier.isNative(modifier)) appender.append("native ");
if (Modifier.isStrict(modifier)) appender.append("strict ");
if (Modifier.isSynchronized(modifier)) appender.append("synchronized ");
if (Modifier.isTransient(modifier)) appender.append("transient ");
}
public static void updateAccessorCounts(TObjectIntMap<String> counts, int[] accessFlags) {
for (int accessFlag : accessFlags) {
if (Modifier.isPublic(accessFlag)) {
counts.adjustOrPutValue("public", 1, 1);
}
if (Modifier.isProtected(accessFlag)) {
counts.adjustOrPutValue("protected", 1, 1);
}
if (Modifier.isPrivate(accessFlag)) {
counts.adjustOrPutValue("private", 1, 1);
}
if (Modifier.isFinal(accessFlag)) {
counts.adjustOrPutValue("final", 1, 1);
}
if (Modifier.isInterface(accessFlag)) {
counts.adjustOrPutValue("interface", 1, 1);
}
if (Modifier.isNative(accessFlag)) {
counts.adjustOrPutValue("native", 1, 1);
}
if (Modifier.isStatic(accessFlag)) {
counts.adjustOrPutValue("static", 1, 1);
}
if (Modifier.isStrict(accessFlag)) {
counts.adjustOrPutValue("strict", 1, 1);
}
if (Modifier.isSynchronized(accessFlag)) {
counts.adjustOrPutValue("synchronized", 1, 1);
}
if (Modifier.isTransient(accessFlag)) {
counts.adjustOrPutValue("transient", 1, 1);
}
if (Modifier.isVolatile(accessFlag)) {
counts.adjustOrPutValue("volatile", 1, 1);
}
if (Modifier.isAbstract(accessFlag)) {
counts.adjustOrPutValue("abstract", 1, 1);
}
}
}
protected void printModifiers(int modifiers) {
if (Modifier.isPublic(modifiers)) {
sb.print("public ");
}
if (Modifier.isProtected(modifiers)) {
sb.print("protected ");
}
if (Modifier.isPrivate(modifiers)) {
sb.print("private ");
}
if (Modifier.isStatic(modifiers)) {
sb.print("static ");
}
if (Modifier.isAbstract(modifiers)) {
sb.print("abstract ");
}
if (Modifier.isFinal(modifiers)) {
sb.print("final ");
}
if (Modifier.isSynchronized(modifiers)) {
sb.print("synchronized ");
}
if (Modifier.isVolatile(modifiers)) {
sb.print("volatile ");
}
if (Modifier.isNative(modifiers)) {
sb.print("native ");
}
if (Modifier.isStrict(modifiers)) {
sb.print("strictfp ");
}
if (Modifier.isTransient(modifiers)) {
sb.print("transient ");
}
if ((modifiers & ElementUtil.ACC_SYNTHETIC) > 0) {
sb.print("synthetic ");
}
}
protected ClassFieldDescription(final Class<?> referenceClass, final Field field,
final ClassFieldDescription parent, final int recursionLevel) {
super();
hierarchyDepth = recursionLevel;
this.parent = parent == null ? Optional.empty() : Optional.of(parent);
if (referenceClass == null) {
if (field == null) {
throw new IllegalArgumentException("field must not be null");
}
this.field = field;
classType = field.getType();
fieldName = field.getName();
if (this.parent.isPresent()) {
final String relativeName = this.parent.get().isRoot() ? "" : (this.parent.get().getFieldNameRelative() + ".");
fieldNameRelative = relativeName + fieldName;
} else {
fieldNameRelative = fieldName;
}
modifierID = field.getModifiers();
} else {
this.field = null; // it's a root, no field definition available
classType = referenceClass;
fieldName = classType.getName();
fieldNameRelative = "";
modifierID = classType.getModifiers();
}
dataType = dataTypeFomClassType(classType);
typeName = ClassDescriptions.translateClassName(classType.getTypeName());
modPublic = Modifier.isPublic(modifierID);
modProtected = Modifier.isProtected(modifierID);
modPrivate = Modifier.isPrivate(modifierID);
modAbstract = Modifier.isAbstract(modifierID);
modStatic = Modifier.isStatic(modifierID);
modFinal = Modifier.isFinal(modifierID);
modTransient = Modifier.isTransient(modifierID);
modVolatile = Modifier.isVolatile(modifierID);
modSynchronized = Modifier.isSynchronized(modifierID);
modNative = Modifier.isNative(modifierID);
modStrict = Modifier.isStrict(modifierID);
modInterface = classType.isInterface();
// additional fields
isprimitive = classType.isPrimitive();
isclass = !isprimitive && !modInterface;
isEnum = Enum.class.isAssignableFrom(classType);
serializable = !modTransient && !modStatic;
}
/**
* 翻译Modifier值
*
* @param mod modifier
* @return 翻译值
*/
public static String modifier(int mod, char splitter) {
StringBuilder sb = new StringBuilder();
if (Modifier.isAbstract(mod)) {
sb.append("abstract").append(splitter);
}
if (Modifier.isFinal(mod)) {
sb.append("final").append(splitter);
}
if (Modifier.isInterface(mod)) {
sb.append("interface").append(splitter);
}
if (Modifier.isNative(mod)) {
sb.append("native").append(splitter);
}
if (Modifier.isPrivate(mod)) {
sb.append("private").append(splitter);
}
if (Modifier.isProtected(mod)) {
sb.append("protected").append(splitter);
}
if (Modifier.isPublic(mod)) {
sb.append("public").append(splitter);
}
if (Modifier.isStatic(mod)) {
sb.append("static").append(splitter);
}
if (Modifier.isStrict(mod)) {
sb.append("strict").append(splitter);
}
if (Modifier.isSynchronized(mod)) {
sb.append("synchronized").append(splitter);
}
if (Modifier.isTransient(mod)) {
sb.append("transient").append(splitter);
}
if (Modifier.isVolatile(mod)) {
sb.append("volatile").append(splitter);
}
if (sb.length() > 0) {
sb.deleteCharAt(sb.length() - 1);
}
return sb.toString();
}
public static boolean isAllModifiersContainSpecificModifier(int allModifiers, int specificModifier) {
if (Modifier.isAbstract(allModifiers) && Modifier.isAbstract(specificModifier))
return true;
if (Modifier.isFinal(allModifiers) && Modifier.isFinal(specificModifier))
return true;
if (Modifier.isInterface(allModifiers) && Modifier.isInterface(specificModifier))
return true;
if (Modifier.isNative(allModifiers) && Modifier.isNative(specificModifier))
return true;
if (Modifier.isPrivate(allModifiers) && Modifier.isPrivate(specificModifier))
return true;
if (Modifier.isProtected(allModifiers) && Modifier.isProtected(specificModifier))
return true;
if (Modifier.isPublic(allModifiers) && Modifier.isPublic(specificModifier))
return true;
if (Modifier.isStatic(allModifiers) && Modifier.isStatic(specificModifier))
return true;
if (Modifier.isStrict(allModifiers) && Modifier.isStrict(specificModifier))
return true;
if (Modifier.isSynchronized(allModifiers) && Modifier.isSynchronized(specificModifier))
return true;
if (Modifier.isTransient(allModifiers) && Modifier.isTransient(specificModifier))
return true;
if (Modifier.isVolatile(allModifiers) && Modifier.isVolatile(specificModifier))
return true;
if (Modifier.isVolatile(allModifiers) && Modifier.isVolatile(specificModifier))
return true;
return false;
}
/**
* @see Modifier#isStrict(int)
*/
default boolean isStrict() {
return Modifier.isStrict(getModifiers());
}
/**
* @return whether the inspected object is strictfp
*/
public boolean isStrict()
{
return Modifier.isStrict(getModifiers());
}
/**
* Returns true if the inspected Class is declared strictfp
* (uses strict floating point math).
* @return whether the inspected class is strictfp
*/
public boolean isStrict()
{
return Modifier.isStrict(getType().getModifiers());
}