指定したクラスの持つ全てのフィールドを再帰的に探索して取得する

@param cls 型
@param fieldMap {@literal Map<String, Field>ｊ}
427061
private static void walkFields(final Class<?> cls, final Map<String, Field> fieldMap) {
		if (cls.equals(Object.class)) {
			return;
		}
		Class<?> superClass = cls.getSuperclass();
		walkFields(superClass, fieldMap);
		Arrays.stream(cls.getDeclaredFields())
				.filter(f -> !Modifier.isStatic(f.getModifiers()))
				.forEach(f -> fieldMap.put(f.getName(), f));
	}
994617
private Map<String, Class<?>> createPropertyMap(Class<?> clz) throws Exception
   {
      Map<String, Class<?>> result = new HashMap<>();

      for (Method m : clz.getMethods())
      {
         if (m.getName().startsWith("set"))
         {
            if (m.getReturnType().equals(Void.TYPE) &&
                m.getParameterCount() == 1 &&
                isSupported(m.getParameterTypes()[0]))
               result.put(m.getName().substring(3), m.getParameterTypes()[0]);
         }
      }
      
      return result;
   }
913984
public static Map<String, Field> getDeepDeclaredFieldMap(Class c)
    {
        Map<String, Field> fieldMap = new HashMap<>();
        Collection<Field> fields = getDeepDeclaredFields(c);
        for (Field field : fields)
        {
            String fieldName = field.getName();
            if (fieldMap.containsKey(fieldName))
            {   // Can happen when parent and child class both have private field with same name
                fieldMap.put(field.getDeclaringClass().getName() + '.' + fieldName, field);
            }
            else
            {
                fieldMap.put(fieldName, field);
            }
        }

        return fieldMap;
    }
151462
public void addSearch(String field, Class<? extends Execution> cls) {
        searches.put(field, cls);
    }
1329969
static Struct newStruct(Map<String, ?> map) {
    Map<String, Value> valueMap = Maps.transformValues(checkNotNull(map), OBJECT_TO_VALUE);
    return Struct.newBuilder().putAllFields(valueMap).build();
  }
878034
public static void addTypeMapper(Class<?> clz, Class<?> mapper) {
		synchronized (classMapper) {
			LinkedHashSet<Class<?>> h = classMapper.get(clz);
			if (h == null) {
				h = new LinkedHashSet<Class<?>>();
				classMapper.put(clz, h);
			}
			
			h.add(mapper);
		}
	}
198502
private void writeMap(String fieldName, Object value) throws IOException
   {
      @SuppressWarnings("unchecked")
      Map<String, Object> map = (Map<String, Object>) value;
      m_writer.writeStartObject(fieldName);
      for (Map.Entry<String, Object> entry : map.entrySet())
      {
         Object entryValue = entry.getValue();
         if (entryValue != null)
         {
            DataType type = TYPE_MAP.get(entryValue.getClass().getName());
            if (type == null)
            {
               type = DataType.STRING;
               entryValue = entryValue.toString();
            }
            writeField(entry.getKey(), type, entryValue);
         }
      }
      m_writer.writeEndObject();
   }
1245678
private static Field[] getBurstableFields(Class<?> cls) {
    final List<Field> fields = new ArrayList<>();

    for (Field field : getAllFields(cls)) {
      if (field.isAnnotationPresent(Burst.class)) {

        if (Modifier.isStatic(field.getModifiers())) {
          throw new IllegalStateException("Burstable field must not be static: " + field.getName());
        }

        if (Modifier.isFinal(field.getModifiers())) {
          throw new IllegalStateException("Burstable field must not be final: " + field.getName());
        }

        fields.add(field);
      }
    }

    return fields.toArray(new Field[fields.size()]);
  }
912480
private static void setFields(final Object from, final Object to,
	                              final Field[] fields, final boolean accessible,
	                              final Map objMap, final Map metadataMap)
	{
		for (int f = 0, fieldsLength = fields.length; f < fieldsLength; ++f)
		{
			final Field field = fields[f];
			final int modifiers = field.getModifiers();
			if ((Modifier.STATIC & modifiers) != 0) continue;
			if ((Modifier.FINAL & modifiers) != 0)
				throw new ObjectCopyException("cannot set final field [" + field.getName() + "] of class [" + from.getClass().getName() + "]");
			if (!accessible && ((Modifier.PUBLIC & modifiers) == 0))
			{
				try
				{
					field.setAccessible(true);
				}
				catch (SecurityException e)
				{
					throw new ObjectCopyException("cannot access field [" + field.getName() + "] of class [" + from.getClass().getName() + "]: " + e.toString(), e);
				}
			}
			try
			{
				cloneAndSetFieldValue(field, from, to, objMap, metadataMap);
			}
			catch (Exception e)
			{
				throw new ObjectCopyException("cannot set field [" + field.getName() + "] of class [" + from.getClass().getName() + "]: " + e.toString(), e);
			}
		}
	}
473999
public static Field getField(Class clazz, String fieldName) {
        if (Map.class.isAssignableFrom(clazz)) {
            return new Field(new MapField(fieldName));
        }
        java.lang.reflect.Field field = null;
        while (field == null && clazz != null) {
            try {
                field = clazz.getDeclaredField(fieldName);
                field.setAccessible(true);
            } catch (Exception e) {
                clazz = clazz.getSuperclass();
            }
        }
        return new Field(field);
    }
602976
@Override
    public void setTypeMap(Map<String,Class<?>> map) throws SQLException
    {
        checkClosed();
        throw SQLError.noSupport();
    }
765815
private void setFields(Map<String, FieldType> map, MapRow row, FieldContainer container)
   {
      if (row != null)
      {
         for (Map.Entry<String, FieldType> entry : map.entrySet())
         {
            container.set(entry.getValue(), row.getObject(entry.getKey()));
         }
      }
   }
1321888
public Field[] getFields(Class clazz, String fieldname) {
	Struct fieldMap;
	Object o;
	synchronized (map) {
	    o = map.get(clazz);
	    if (o == null) {
		fieldMap = store(clazz);
	    }
	    else fieldMap = (Struct) o;
	}
	o = fieldMap.get(fieldname, null);
	if (o == null) return null;
	return (Field[]) o;

    }
375034
protected void getFieldMappings()
            throws SQLException {

        final String[] keys = getKeysFromResultSet();

        //
        // find fields or setters for return class
        //
        HashMap<String, AccessibleObject> mapFields = new HashMap<String, AccessibleObject>(_columnCount * 2);
        for (int i = 1; i <= _columnCount; i++) {
            mapFields.put(keys[i], null);
        }

        // public methods
        Method[] classMethods = _returnTypeClass.getMethods();
        for (Method m : classMethods) {

            if (isSetterMethod(m)) {
                final String fieldName = m.getName().substring(3).toUpperCase();
                if (mapFields.containsKey(fieldName)) {

                    // check for overloads
                    Object field = mapFields.get(fieldName);
                    if (field == null) {
                        mapFields.put(fieldName, m);
                    } else {
                        throw new ControlException("Unable to choose between overloaded methods " + m.getName()
                                                   + " on the " + _returnTypeClass.getName() + " class. Mapping is done using "
                                                   + "a case insensitive comparision of SQL ResultSet columns to field "
                                                   + "names and public setter methods on the return class.");
                    }
                }
            }
        }

        // fix for 8813: include inherited and non-public fields
        for (Class clazz = _returnTypeClass; clazz != null && clazz != Object.class; clazz = clazz.getSuperclass()) {
            Field[] classFields = clazz.getDeclaredFields();
            for (Field f : classFields) {
                if (Modifier.isStatic(f.getModifiers())) continue;
                if (!Modifier.isPublic(f.getModifiers())) continue;
                String fieldName = f.getName().toUpperCase();
                if (!mapFields.containsKey(fieldName)) continue;

                Object field = mapFields.get(fieldName);
                if (field == null) {
                    mapFields.put(fieldName, f);
                }
            }
        }

        // finally actually init the fields array
        _fields = new AccessibleObject[_columnCount + 1];
        _fieldTypes = new int[_columnCount + 1];

        for (int i = 1; i < _fields.length; i++) {
            AccessibleObject f = mapFields.get(keys[i]);
            if (f == null) {
                throw new ControlException("Unable to map the SQL column " + keys[i]
                                           + " to a field on the " + _returnTypeClass.getName() +
                                           " class. Mapping is done using a case insensitive comparision of SQL ResultSet "
                                           + "columns to field names and public setter methods on the return class.");
            }

            _fields[i] = f;
            if (f instanceof Field) {
                _fieldTypes[i] = _tmf.getTypeId(((Field) f).getType());
            } else {
                _fieldTypes[i] = _tmf.getTypeId(((Method) f).getParameterTypes()[0]);
            }
        }
    }
1258402
private Map<String, TField> computeFieldNameMap(Class<?> clazz) {
        final Map<String, TField> map = new HashMap<>();

        if (isTBase(clazz)) {
            // Get the metaDataMap for this Thrift class
            @SuppressWarnings("unchecked")
            final Map<? extends TFieldIdEnum, FieldMetaData> metaDataMap =
                    FieldMetaData.getStructMetaDataMap((Class<? extends TBase<?, ?>>) clazz);

            for (Entry<? extends TFieldIdEnum, FieldMetaData> e : metaDataMap.entrySet()) {
                final String fieldName = e.getKey().getFieldName();
                final FieldMetaData metaData = e.getValue();

                final FieldValueMetaData elementMetaData;
                if (metaData.valueMetaData.isContainer()) {
                    if (metaData.valueMetaData instanceof SetMetaData) {
                        elementMetaData = ((SetMetaData) metaData.valueMetaData).elemMetaData;
                    } else if (metaData.valueMetaData instanceof ListMetaData) {
                        elementMetaData = ((ListMetaData) metaData.valueMetaData).elemMetaData;
                    } else if (metaData.valueMetaData instanceof MapMetaData) {
                        elementMetaData = ((MapMetaData) metaData.valueMetaData).valueMetaData;
                    } else {
                        // Unrecognized container type, but let's still continue processing without
                        // special enum support.
                        elementMetaData = metaData.valueMetaData;
                    }
                } else {
                    elementMetaData = metaData.valueMetaData;
                }

                if (elementMetaData instanceof EnumMetaData) {
                    classMap.put(fieldName, ((EnumMetaData) elementMetaData).enumClass);
                } else if (elementMetaData instanceof StructMetaData) {
                    classMap.put(fieldName, ((StructMetaData) elementMetaData).structClass);
                }

                // Workaround a bug in the generated thrift message read()
                // method by mapping the ENUM type to the INT32 type
                // The thrift generated parsing code requires that, when expecting
                // a value of enum, we actually parse a value of type int32. The
                // generated read() method then looks up the enum value in a map.
                final byte type = TType.ENUM == metaData.valueMetaData.type ? TType.I32
                                                                            : metaData.valueMetaData.type;

                map.put(fieldName,
                        new TField(fieldName,
                                   type,
                                   e.getKey().getThriftFieldId()));
            }
        } else { // TApplicationException
            map.put("message", new TField("message", (byte)11, (short)1));
            map.put("type", new TField("type", (byte)8, (short)2));
        }

        return map;
    }
466519
public void setCustomFields(Map<String, String> fields) {
        clearCustomFields();
        for (String key : fields.keySet()) {
            CustomField f = new CustomField();
            f.setName(key);
            f.setValue(fields.get(key));
            customFields.add(f);
        }
    }
27293
private static Field getField(final Class cls, final String fieldName, boolean declared) {
		$.checkNotEmpty(fieldName);
		List<Field> fields = getFieldsList(cls, declared);
		for (int i = 0; i < fields.size(); i++) {
			if (fieldName.equals(fields.get(i).getName())) {
				return fields.get(i);
			}
		}
		return null;
	}