Get fields as properties
@param obj the object to get fields for
@param clazzes the classes to use for reflection and properties.
T
@return the fields as properties
1401
public static Properties getFieldsAsProperties(Object obj, Class<?>[] clazzes) throws Exception {
        Properties props = new Properties();
        for (Field field : obj.getClass().getDeclaredFields()) {
            if (Modifier.isStatic(field.getModifiers()))
                continue;
            field.setAccessible(true);
            Class<?> type = field.getType();
            if (clazzes == null || contains(type, clazzes)) {
                Object val = field.get(obj);
                if (val != null)
                    props.put(field.getName(), val.toString());

            }
        }

        return props;
    }
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);
    }
1066436
Object getObjectFromConstantFields(Class cls) {
		Field[] fields = cls.getFields();
		Object instance = null;
		for (Field field : fields) {
			instance = getObjectFromConstantField(cls, field);
			if(instance!=null) {
				break;
			}
		}
		return instance;
	}
652563
private Field[] getAllInstanceFields(final Object obj) {
		Field[] fields = instanceFieldsByClass.get(obj.getClass());

		if (fields == null) {
			List<Field> fieldList = ReflectionUtil.
					getAllFields(obj, excludeStatic, excludeTransient);
			fields = fieldList.toArray(new Field[fieldList.size()]);

			instanceFieldsByClass.put(obj.getClass(), fields);
		}

		return fields;
	}
884932
public static Object[] getFieldsValue(Object obj) {
		if (null != obj) {
			final Field[] fields = getFields(obj.getClass());
			if (null != fields) {
				final Object[] values = new Object[fields.length];
				for (int i = 0; i < fields.length; i++) {
					values[i] = getFieldValue(obj, fields[i]);
				}
				return values;
			}
		}
		return null;
	}
1011189
@Nonnull
  public <T> List<T> toObjects(@Nonnull Class<T> clazz) {
    List<T> results = new ArrayList<>();

    for (DocumentSnapshot documentSnapshot : getDocuments()) {
      results.add(CustomClassMapper.convertToCustomClass(documentSnapshot.getData(), clazz));
    }

    return results;
  }
1165046
public static Field getPropertyField(Class<?> clazz, String propertyPath) {
		
		Field propertyField = null;
		try {
			String[] properties = propertyPath.split("\\.");
			Field carField = getDeclaredFieldInHierarchy(clazz, properties[0]); 
			if (properties.length == 1) {
				propertyField = carField;
			} else {
				String cdr = StringUtils.arrayToDelimitedString(
						Arrays.copyOfRange(properties, 1, properties.length), ".");
				propertyField = getPropertyField(carField.getType(), cdr);
			}
		} catch (Exception e) {
			throw new IllegalArgumentException("Error accessing propertyPath: " + propertyPath + 
					" on class: " + clazz.getName(), e);
		}
		return propertyField;
	}
300625
public static Field[] getAllFields(Class<?> clz) {
    List<Field> list = new ArrayList<>();
    do {
      list.addAll(Arrays.asList(clz.getDeclaredFields()));
    } while ((clz = clz.getSuperclass()) != null);
    return list.toArray(new Field[list.size()]);
  }
810045
public static List<Field> retrievePropertyList(final Class<?> cls) {
        final List<Field> propertyList = new ArrayList<>();
        for (final Field f : cls.getFields()) {
            propertyList.add(f);
        }
        return propertyList;
    }
21604
public static <T extends Annotation> Set<Field> getAnnotatedPublicFields(Class<? extends Object> clazz,
			Class<T> annotation) {

		if (Object.class.equals(clazz)) {
			return Collections.emptySet();
		}

		Set<Field> annotatedFields = new HashSet<Field>();
		Field[] fields = clazz.getFields();

		for (Field field : fields) {
			if (field.getAnnotation(annotation) != null) {
				annotatedFields.add(field);
			}
		}

		return annotatedFields;
	}
574838
@SuppressWarnings("unchecked")
    public <T> Set<T> getSet(Class<T> clazz) {
        return (Set<T>) objects;
    }
1075984
public static function getProperties($obj)
    {
        $properties = array();
        try {
            $rc = new ReflectionClass($obj);
            do {
                $rp = array();

                // Note that we will not include any properties in traits
                $traits = $rc->getTraits();
                $skipProperties = array();
                if (!empty($traits)) {
                    foreach ($traits as $trait) {
                        foreach ($trait->getProperties() as $traitProperty) {
                            $skipProperties[] = $traitProperty->getName();
                        }
                    }
                }
                /* @var $p \ReflectionProperty */
                foreach ($rc->getProperties() as $p) {
                    if (in_array($p->getName(), $skipProperties, true)) {
                        continue;
                    }
                    $p->setAccessible(true);
                    $rp[$p->getName()] = $p->getValue($obj);
                }
                $properties = array_merge($rp, $properties);
            } while ($rc = $rc->getParentClass());
        } catch (ReflectionException $e) {
            //
        }
        return $properties;
    }
44552
protected List<Field> getFields(Class<?> clazz) {
        List<Field> fields = new ArrayList<Field>();

        while (clazz != null && !isBoundaryClass(clazz)) {
            for (Field field : clazz.getDeclaredFields()) {
                if (!field.isAnnotationPresent(Inject.class)) {
                    continue;
                }
                fields.add(field);
            }
            clazz = clazz.getSuperclass();
        }
        return fields;
    }
1040450
private Field[] fields(Class<?> clazz)
    {

        Map<String, Field> fields = new HashMap<String, Field>();
        do
        {
            for (Field field : clazz.getDeclaredFields())
            {
                if (!fields.containsKey(field.getName()))
                {
                    fields.put(field.getName(), field);
                }
            }
            clazz = clazz.getSuperclass();
        }
        while (clazz != Object.class);

        return fields.values().toArray(new Field[fields.size()]);

    }
16583
public static List<Field> getAllFields(Class<?> clazz) {
        final List<Field> ret = new ArrayList<>();
        do {
            ret.addAll(Arrays.asList(clazz.getDeclaredFields()));
            clazz = clazz.getSuperclass();
        } while (clazz != null);
        return ret;
    }
1202611
private Set<Annotation> getFieldAnnotations(final Class<?> clazz)
	{
		try
		{
			return new LinkedHashSet<Annotation>(asList(clazz.getDeclaredField(propertyName).getAnnotations()));
		}
		catch (final NoSuchFieldException e)
		{
			if (clazz.getSuperclass() != null)
			{
				return getFieldAnnotations(clazz.getSuperclass());
			}
			else
			{
				logger.debug("Cannot find propertyName: {}, declaring class: {}", propertyName, clazz);
				return new LinkedHashSet<Annotation>(0);
			}
		}
	}
904175
public static Map<String, PropertyDescriptor> mapPropertyDescriptors(Class<?> clazz) {
        PropertyDescriptor[] properties = propertyDescriptors(clazz);
        Map<String, PropertyDescriptor> mappedProperties = new HashMap<String, PropertyDescriptor>();

        for (PropertyDescriptor property : properties) {
            if ("class".equals(property.getName()) == false) {
                mappedProperties.put(property.getName(), property);
            }
        }

        return mappedProperties;
    }