當前位置: 首頁>>代碼示例>>Java>>正文


Java Modifier.isTransient方法代碼示例

本文整理匯總了Java中java.lang.reflect.Modifier.isTransient方法的典型用法代碼示例。如果您正苦於以下問題:Java Modifier.isTransient方法的具體用法?Java Modifier.isTransient怎麽用?Java Modifier.isTransient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.reflect.Modifier的用法示例。


在下文中一共展示了Modifier.isTransient方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFields

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
public Map<String, FieldInfo> getFields(final Type entityClass) {
	Map<String, FieldInfo> fields = cache.get(entityClass);
	if (fields == null) {
		fields = new HashMap<String, VPackCache.FieldInfo>();
		Class<?> tmp = (Class<?>) entityClass;
		while (tmp != null && tmp != Object.class) {
			final Field[] declaredFields = tmp.getDeclaredFields();
			for (final Field field : declaredFields) {
				if (!field.isSynthetic() && !Modifier.isStatic(field.getModifiers())
						&& !Modifier.isTransient(field.getModifiers())) {
					field.setAccessible(true);
					final FieldInfo fieldInfo = createFieldInfo(field);
					if (fieldInfo.serialize || fieldInfo.deserialize) {
						fields.put(fieldInfo.getFieldName(), fieldInfo);
					}
				}
			}
			tmp = tmp.getSuperclass();
		}
		fields = sort(fields.entrySet());
		cache.put(entityClass, fields);
	}
	return fields;
}
 
開發者ID:arangodb,項目名稱:java-velocypack,代碼行數:25,代碼來源:VPackCache.java

示例2: getBeanPropertyFields

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
public static Map<String, Field> getBeanPropertyFields(Class cl) {
    Map<String, Field> properties = new HashMap<String, Field>();
    for(; cl != null; cl = cl.getSuperclass()) {
        Field[] fields = cl.getDeclaredFields();
        for(Field field : fields) {
            if (Modifier.isTransient(field.getModifiers())
                || Modifier.isStatic(field.getModifiers())) {
                continue;
            }

            field.setAccessible(true);

            properties.put(field.getName(), field);
        }
    }

    return properties;
}
 
開發者ID:flychao88,項目名稱:dubbocloud,代碼行數:19,代碼來源:ReflectUtils.java

示例3: getFieldList

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
/**
 * 獲取該類的所有屬性列表
 *
 * @param clazz 反射類
 * @return
 */
public static List<Field> getFieldList(Class<?> clazz) {
    if (null == clazz) {
        return null;
    }
    List<Field> fieldList = new LinkedList<>();
    Field[] fields = clazz.getDeclaredFields();
    for (Field field : fields) {
        /* 過濾靜態屬性 */
        if (Modifier.isStatic(field.getModifiers())) {
            continue;
        }
        /* 過濾 transient關鍵字修飾的屬性 */
        if (Modifier.isTransient(field.getModifiers())) {
            continue;
        }
        fieldList.add(field);
    }
    /* 處理父類字段 */
    Class<?> superClass = clazz.getSuperclass();
    if (superClass.equals(Object.class)) {
        return fieldList;
    }
    /* 排除重載屬性 */
    return excludeOverrideSuperField(fieldList, getFieldList(superClass));
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:32,代碼來源:ReflectionKit.java

示例4: getNonStaticFields

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
/**
 * Get all non-static fields of the Class passed in or its super classes.
 *
 * @param clazz
 *            Class to parse.
 * @return field list
 */
public static List<Field> getNonStaticFields(final Class<?> clazz) {
    List<Field> result = new ArrayList<Field>();
    Class<?> target = clazz;
    while (target != null) {
        if (JaketConfigurationUtils.isExcludedType(target)) {
            break;
        }

        Field[] fields = target.getDeclaredFields();
        for (Field field : fields) {
            int modifiers = field.getModifiers();
            if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) {
                continue;
            }

            result.add(field);
        }
        target = target.getSuperclass();
    }

    return result;
}
 
開發者ID:venus-boot,項目名稱:saluki,代碼行數:30,代碼來源:ClassUtils.java

示例5: writeObject

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
private void writeObject(String key, Object object) throws IllegalArgumentException, IllegalAccessException {
	if (alreadyWritten.containsKey(object)) {
		throw new IllegalArgumentException("Object " + object + " is already present in the stream");
	}
	alreadyWritten.put(object, object);

	writer.beginObject(key, object.getClass().getName());

	Class<?> clazz = object.getClass();
	while (clazz != Object.class) {
		Field[] fields = clazz.getDeclaredFields();
		for (Field field : fields) {
			field.setAccessible(true);

			int modifiers = field.getModifiers();
			if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers) || Modifier.isVolatile(modifiers)) {
				// Skip
				continue;
			}
			if (field.isSynthetic()) {
				// Skip
				continue;
			}

			writeProperty(field.getName(), field.get(object));
		}

		clazz = clazz.getSuperclass();
	}

	writer.endObject();
}
 
開發者ID:Puppygames,項目名稱:thjson,代碼行數:33,代碼來源:POJOtoTHJSONConverter.java

示例6: getProfileMeasurements

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
/**
 * Return a list of all of the ProfileMeasurement handles for this profiler
 * @return
 */
public final ProfileMeasurement[] getProfileMeasurements() {
    if (pm_cache == null) {
        synchronized (this) {
            if (pm_cache == null) {
                final List<ProfileMeasurement> temp = new ArrayList<ProfileMeasurement>();
                for (Field f : this.getClass().getDeclaredFields()) {
                    int modifiers = f.getModifiers();
                    if (Modifier.isTransient(modifiers) == false &&
                        Modifier.isPrivate(modifiers) == false &&
                        Modifier.isStatic(modifiers) == false) {
                        
                        Object obj = null;
                        try {
                            obj = f.get(this);
                        } catch (Exception ex) {
                            throw new RuntimeException("Failed to get value for field '" + f.getName() + "'", ex);
                        }
                        if (obj instanceof ProfileMeasurement) temp.add((ProfileMeasurement)obj);
                    }
                } // FOR
                pm_cache = temp.toArray(new ProfileMeasurement[temp.size()]);
            }
        } // SYNCH
    }
    return (pm_cache);
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:31,代碼來源:AbstractProfiler.java

示例7: getFieldsByType

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
/**
 * @param clazz
 * @return
 */
public static <T> Field[] getFieldsByType(Class<?> clazz, Class<? extends T> fieldType) {
    List<Field> fields = new ArrayList<Field>();
    for (Field f : clazz.getDeclaredFields()) {
        int modifiers = f.getModifiers();
        if (Modifier.isTransient(modifiers) == false &&
            Modifier.isPublic(modifiers) == true &&
            Modifier.isStatic(modifiers) == false &&
            ClassUtil.getSuperClasses(f.getType()).contains(fieldType)) {
            
            fields.add(f);
        }
    } // FOR
    return (fields.toArray(new Field[fields.size()]));
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:19,代碼來源:ClassUtil.java

示例8: isPersistableField

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
/**
 * Is this field persistable.
 */
static boolean isPersistableField(Field f) {
	if (f.isAnnotationPresent(Transient.class)) {
		return false;
	}
	int mod = f.getModifiers();
	if (Modifier.isFinal(mod) || Modifier.isTransient(mod) || Modifier.isStatic(mod)) {
		return false;
	}
	getSqlType(f);
	return true;
}
 
開發者ID:michaelliao,項目名稱:crypto-exchange,代碼行數:15,代碼來源:EntityInfo.java

示例9: isTransient

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
@Override
public boolean isTransient() {
    Field field = fieldInBack();
    return field != null && Modifier.isTransient(field.getModifiers());
}
 
開發者ID:cybozu,項目名稱:spring-data-jdbc-template,代碼行數:6,代碼來源:Accessors.java

示例10: loadFields

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
static void loadFields( IJsonIO obj, Class cls, Bindings bindings )
{
  Field[] fields = cls.getDeclaredFields();
  for( Field f : fields )
  {
    if( f.isSynthetic() || Modifier.isStatic( f.getModifiers() ) || Modifier.isTransient( f.getModifiers() ) )
    {
      continue;
    }
    f.setAccessible( true );
    try
    {
      Object value = bindings.get( f.getName() );
      if( value instanceof Bindings )
      {
        value = read( (Bindings)value );
      }
      else if( value instanceof List && ((List)value).size() > 0 && ((List)value).get( 0 ) instanceof Bindings )
      {
        value = readList( bindings );
      }
      else if( f.getType().isEnum() && value instanceof String )
      {
        value = Enum.valueOf( (Class)f.getType(), (String)value );
      }
      else if( f.getType() == Boolean.class || f.getType() == boolean.class )
      {
        value = (Integer)value != 0;
      }
      else if( !isSimpleType( f.getType() ) )
      {
        throw new UnsupportedOperationException( "Unsupported Json type: " + f.getType() );
      }
      f.set( obj, value );
    }
    catch( IllegalAccessException e )
    {
      throw new RuntimeException( e );
    }
  }
  Class superclass = cls.getSuperclass();
  if( superclass != null )
  {
    loadFields( obj, superclass, bindings );
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:47,代碼來源:IJsonIO.java

示例11: isTransient

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
/** Returns true if the field is transient. */
final boolean isTransient() {
  return Modifier.isTransient(getModifiers());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:5,代碼來源:Element.java

示例12: isTransient

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
/**
 * @see Modifier#isTransient(int)
 */
default boolean isTransient() {
    return Modifier.isTransient(getModifiers());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:ModifiersProvider.java

示例13: isTransient

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
public boolean isTransient(Field f) {
    return Modifier.isTransient(f.getModifiers());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:ReflectionNavigator.java

示例14: computeStructuralUID

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
public static long computeStructuralUID(boolean hasWriteObject, Class<?> cl) {
    ByteArrayOutputStream devnull = new ByteArrayOutputStream(512);

    long h = 0;
    try {

        if ((!java.io.Serializable.class.isAssignableFrom(cl)) ||
            (cl.isInterface())){
            return 0;
        }

        if (java.io.Externalizable.class.isAssignableFrom(cl)) {
            return 1;
        }

        MessageDigest md = MessageDigest.getInstance("SHA");
        DigestOutputStream mdo = new DigestOutputStream(devnull, md);
        DataOutputStream data = new DataOutputStream(mdo);

        //In the old case, for the caller class, the write Method wasn't considered
        // for rep-id calculations correctly, but for parent classes it was taken
        // into account.  That is the reason there is the klude of getting the write
        // Object method in there

        // Get SUID of parent
        Class<?> parent = cl.getSuperclass();
        if ((parent != null) && (parent != java.lang.Object.class)) {
            boolean hasWriteObjectFlag = false;
            Class [] args = {java.io.ObjectOutputStream.class};
            Method hasWriteObjectMethod = ObjectStreamClassUtil_1_3.getDeclaredMethod(parent, "writeObject", args,
                   Modifier.PRIVATE, Modifier.STATIC);
            if (hasWriteObjectMethod != null)
                hasWriteObjectFlag = true;
            data.writeLong(ObjectStreamClassUtil_1_3.computeStructuralUID(hasWriteObjectFlag, parent));
        }

        if (hasWriteObject)
            data.writeInt(2);
        else
            data.writeInt(1);

        /* Sort the field names to get a deterministic order */
        Field[] field = ObjectStreamClassUtil_1_3.getDeclaredFields(cl);
        Arrays.sort(field, compareMemberByName);

        for (int i = 0; i < field.length; i++) {
            Field f = field[i];

                            /* Include in the hash all fields except those that are
                             * transient or static.
                             */
            int m = f.getModifiers();
            if (Modifier.isTransient(m) || Modifier.isStatic(m))
                continue;

            data.writeUTF(f.getName());
            data.writeUTF(getSignature(f.getType()));
        }

        /* Compute the hash value for this class.
         * Use only the first 64 bits of the hash.
         */
        data.flush();
        byte hasharray[] = md.digest();
        int minimum = Math.min(8, hasharray.length);
        for (int i = minimum; i > 0; i--) {
            h += (long)(hasharray[i] & 255) << (i * 8);
        }
    } catch (IOException ignore) {
        /* can't happen, but be deterministic anyway. */
        h = -1;
    } catch (NoSuchAlgorithmException complain) {
        throw new SecurityException(complain.getMessage());
    }
    return h;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:77,代碼來源:ObjectStreamClassUtil_1_3.java

示例15: includeField

import java.lang.reflect.Modifier; //導入方法依賴的package包/類
/**
 * Returns true if fields with {@code modifiers} are included in the emitted JSON.
 */
@SuppressWarnings("SimplifiableIfStatement")
private boolean includeField(boolean platformType, int modifiers) {
    if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) return false;
    return Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers) || !platformType;
}
 
開發者ID:pCloud,項目名稱:pcloud-networking-java,代碼行數:9,代碼來源:ClassTypeAdapterFactory.java


注:本文中的java.lang.reflect.Modifier.isTransient方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。