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


Java Field.isSynthetic方法代碼示例

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


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

示例1: findAnnotatedFields

import java.lang.reflect.Field; //導入方法依賴的package包/類
public static Collection<Field> findAnnotatedFields(Class<?> type, Class<? extends Annotation> annotation)
{
    List<Field> result = new ArrayList<>();

    // gather all publicly available fields
    // this returns everything, even if it's declared in a parent
    for (Field field : type.getFields()) {
        if (field.isSynthetic() || isStatic(field.getModifiers())) {
            continue;
        }

        if (field.isAnnotationPresent(annotation)) {
            result.add(field);
        }
    }

    return result;
}
 
開發者ID:airlift,項目名稱:drift,代碼行數:19,代碼來源:ReflectionHelper.java

示例2: getAllFields

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * Geef alle velden van een klasse (inclusief velden uit super klassen, exclusief
 * java.lang.Object).
 * @param clazz klasse
 * @return lijst van alle velden
 */
public static Field[] getAllFields(final Class<?> clazz) {
    final java.util.List<Field> result = new ArrayList<>();

    Class<?> theClazz = clazz;
    while (theClazz != null && !Object.class.equals(theClazz)) {
        for (final Field field : theClazz.getDeclaredFields()) {
            if (!field.isSynthetic()) {
                result.add(field);
            }
        }
        theClazz = theClazz.getSuperclass();
    }

    return result.toArray(new Field[]{});
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:22,代碼來源:ReflectionUtils.java

示例3: findClassField

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * Tries to find a class fields. Supports inheritance and doesn't return synthetic fields.
 *
 * @param beanClass class to be searched for
 * @param fieldName field name
 * @return a list of found fields
 */
public static Field findClassField(Class<?> beanClass, String fieldName) {
	Class<?> currentClass = beanClass;
	while (currentClass != null && currentClass != Object.class) {
		for (Field field : currentClass.getDeclaredFields()) {
			if (field.isSynthetic()) {
				continue;
			}

			if (field.getName().equals(fieldName)) {
				return field;
			}
		}
		currentClass = currentClass.getSuperclass();
	}

	return null;
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:25,代碼來源:ClassUtils.java

示例4: validateClass

import java.lang.reflect.Field; //導入方法依賴的package包/類
private void validateClass(Class<?> source, RuleSourceValidationProblemCollector problems) {
    int modifiers = source.getModifiers();

    if (Modifier.isInterface(modifiers)) {
        problems.add("Must be a class, not an interface");
    }

    if (source.getEnclosingClass() != null) {
        if (Modifier.isStatic(modifiers)) {
            if (Modifier.isPrivate(modifiers)) {
                problems.add("Class cannot be private");
            }
        } else {
            problems.add("Enclosed classes must be static and non private");
        }
    }

    Constructor<?>[] constructors = source.getDeclaredConstructors();
    for (Constructor<?> constructor : constructors) {
        if (constructor.getParameterTypes().length > 0) {
            problems.add("Cannot declare a constructor that takes arguments");
            break;
        }
    }

    Field[] fields = source.getDeclaredFields();
    for (Field field : fields) {
        int fieldModifiers = field.getModifiers();
        if (!field.isSynthetic() && !(Modifier.isStatic(fieldModifiers) && Modifier.isFinal(fieldModifiers))) {
            problems.add(field, "Fields must be static final.");
        }
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:34,代碼來源:ModelRuleExtractor.java

示例5: ensureNoInstanceScopedFields

import java.lang.reflect.Field; //導入方法依賴的package包/類
private static void ensureNoInstanceScopedFields(StructBindingValidationProblemCollector problems, Class<?> typeClass) {
    List<Field> declaredFields = Arrays.asList(typeClass.getDeclaredFields());
    for (Field field : declaredFields) {
        int fieldModifiers = field.getModifiers();
        if (!field.isSynthetic() && !(Modifier.isStatic(fieldModifiers) && Modifier.isFinal(fieldModifiers))) {
            problems.add(field, "Fields must be static final.");
        }
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:10,代碼來源:DefaultStructBindingsStore.java

示例6: filterSynthetics

import java.lang.reflect.Field; //導入方法依賴的package包/類
private static void filterSynthetics(List<Field> fields) {
    if (fields == null || fields.isEmpty()) return;
    Iterator<Field> iterator = fields.iterator();
    while (iterator.hasNext()) {
        Field f = iterator.next();
        if (f.isSynthetic()) iterator.remove();
    }
}
 
開發者ID:dizitart,項目名稱:nitrite-database,代碼行數:9,代碼來源:ReflectionUtils.java

示例7: relevantFields

import java.lang.reflect.Field; //導入方法依賴的package包/類
static ImmutableSet<Field> relevantFields(Class<?> cls) {
  ImmutableSet.Builder<Field> builder = ImmutableSet.builder();
  for (Field field : cls.getDeclaredFields()) {
    /*
     * Coverage mode generates synthetic fields.  If we ever add private
     * fields, they will cause similar problems, and we may want to switch
     * this check to isAccessible().
     */
    if (!field.isSynthetic() && field.getType() == String.class) {
      builder.add(field);
    }
  }
  return builder.build();
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:15,代碼來源:HttpHeadersTest.java

示例8: isHiddenField

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * Is this field to be hidden from the graph?
 */
private static boolean isHiddenField(Field field) {
  if (field.isSynthetic() || has(field, Hidden.class) || isStatic(field.getModifiers())) {
    return true;
  }
  return SYSTEM_PROPERTIES.contains(propertyKey(field)) ||
      SYSTEM_CLASSES.contains(field.getDeclaringClass()) ||
      isFunctional(field.getType());
}
 
開發者ID:karthicks,項目名稱:gremlin-ogm,代碼行數:12,代碼來源:Fields.java

示例9: registerField

import java.lang.reflect.Field; //導入方法依賴的package包/類
private void registerField(Map<String, Getter> getters, Map<String, Setter> setters, Field field) {
    if(Modifier.isTransient(field.getModifiers()) ||
       Modifier.isStatic(field.getModifiers()) ||
       field.isSynthetic() ||
       field.isEnumConstant()) return;

    final String name = serializedName(field);
    final boolean gettable = !getters.containsKey(name);
    final boolean settable = !setters.containsKey(name);

    if(gettable || settable) {
        if(logger.isLoggable(Level.FINE)) {
            String access;
            if(gettable && settable) {
                access = "get/set";
            } else if(gettable) {
                access = "get";
            } else {
                access = "set";
            }
            logger.fine("  " + name + " -- " + access + " --> " + field);
        }

        if(gettable) {
            getters.put(name, new FieldGetter(this, field));
        }

        if(settable) {
            setters.put(name, new FieldSetter(this, field));
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:33,代碼來源:DocumentRegistry.java

示例10: excludeField

import java.lang.reflect.Field; //導入方法依賴的package包/類
public boolean excludeField(Field field, boolean serialize) {
    if ((this.modifiers & field.getModifiers()) != 0) {
        return true;
    }
    if (this.version != IGNORE_VERSIONS && !isValidVersion((Since) field.getAnnotation(Since
            .class), (Until) field.getAnnotation(Until.class))) {
        return true;
    }
    if (field.isSynthetic()) {
        return true;
    }
    if (this.requireExpose) {
        Expose annotation = (Expose) field.getAnnotation(Expose.class);
        if (annotation == null || (serialize ? !annotation.serialize() : !annotation
                .deserialize())) {
            return true;
        }
    }
    if (!this.serializeInnerClasses && isInnerClass(field.getType())) {
        return true;
    }
    if (isAnonymousOrLocal(field.getType())) {
        return true;
    }
    List<ExclusionStrategy> list = serialize ? this.serializationStrategies : this
            .deserializationStrategies;
    if (!list.isEmpty()) {
        FieldAttributes fieldAttributes = new FieldAttributes(field);
        for (ExclusionStrategy exclusionStrategy : list) {
            if (exclusionStrategy.shouldSkipField(fieldAttributes)) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:37,代碼來源:Excluder.java

示例11: resetCounters

import java.lang.reflect.Field; //導入方法依賴的package包/類
public static void resetCounters() throws Exception {
  Class<?> cl = SplitLogCounters.class;
  for (Field fld : cl.getDeclaredFields()) {
    /* Guard against source instrumentation. */
    if ((!fld.isSynthetic()) && (AtomicLong.class.isAssignableFrom(fld.getType()))) {
      ((AtomicLong)fld.get(null)).set(0);
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:10,代碼來源:SplitLogCounters.java

示例12: isPublicInstanceField

import java.lang.reflect.Field; //導入方法依賴的package包/類
protected static boolean isPublicInstanceField(Field field) {
    return Modifier.isPublic(field.getModifiers())
            && !Modifier.isStatic(field.getModifiers())
            && !Modifier.isFinal(field.getModifiers())
            && !field.isSynthetic();
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:7,代碼來源:ReflectUtils.java

示例13: isPublicInstanceField

import java.lang.reflect.Field; //導入方法依賴的package包/類
public static boolean isPublicInstanceField(Field field) {
    return Modifier.isPublic(field.getModifiers())
        && !Modifier.isStatic(field.getModifiers())
        && !Modifier.isFinal(field.getModifiers())
        && !field.isSynthetic();
}
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:7,代碼來源:ReflectUtils.java

示例14: saveFields

import java.lang.reflect.Field; //導入方法依賴的package包/類
static void saveFields( IJsonIO obj, Class cls, Bindings bindings )
{
  Class superclass = cls.getSuperclass();
  if( superclass != null )
  {
    saveFields( obj, superclass, 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 = f.get( obj );
      if( isSimpleType( value ) )
      {
        bindings.put( f.getName(), value );
      }
      else if( value instanceof Enum )
      {
        bindings.put( f.getName(), ((Enum)value).name() );
      }
      else if( value instanceof Boolean )
      {
        bindings.put( f.getName(), (Boolean)value ? 1 : 0 );
      }
      else if( value instanceof List )
      {
        if( !((List)value).isEmpty() )
        {
          if( isSimpleType( ((List)value).get( 0 ) ) )
          {
            bindings.put( f.getName(), value );
          }
          else
          {
            writeList( f.getName(), (List)value, bindings );
          }
        }
        else
        {
          bindings.put( f.getName(), value );
        }
      }
      else if( value instanceof IJsonIO )
      {
        write( f.getName(), (IJsonIO)value, bindings );
      }
      else
      {
        throw new UnsupportedOperationException( "Type: " + value.getClass() + " does not implement " + IJsonIO.class.getName() );
      }
    }
    catch( IllegalAccessException e )
    {
      throw new RuntimeException( e );
    }
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:65,代碼來源:IJsonIO.java

示例15: excludeField

import java.lang.reflect.Field; //導入方法依賴的package包/類
public boolean excludeField(Field field, boolean serialize) {
  if ((modifiers & field.getModifiers()) != 0) {
    return true;
  }

  if (version != Excluder.IGNORE_VERSIONS
      && !isValidVersion(field.getAnnotation(Since.class), field.getAnnotation(Until.class))) {
    return true;
  }

  if (field.isSynthetic()) {
    return true;
  }

  if (requireExpose) {
    Expose annotation = field.getAnnotation(Expose.class);
    if (annotation == null || (serialize ? !annotation.serialize() : !annotation.deserialize())) {
      return true;
    }
  }

  if (!serializeInnerClasses && isInnerClass(field.getType())) {
    return true;
  }

  if (isAnonymousOrLocal(field.getType())) {
    return true;
  }

  List<ExclusionStrategy> list = serialize ? serializationStrategies : deserializationStrategies;
  if (!list.isEmpty()) {
    FieldAttributes fieldAttributes = new FieldAttributes(field);
    for (ExclusionStrategy exclusionStrategy : list) {
      if (exclusionStrategy.shouldSkipField(fieldAttributes)) {
        return true;
      }
    }
  }

  return false;
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:42,代碼來源:Excluder.java


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