Factory to create a property avoiding duplicate generics.

@param <P>  the property type
@param bean  the bean that the property is bound to, not null
@param metaProperty  the meta property, not null
@return the property, not null
337773
public static <P> BasicProperty<P> of(Bean bean, MetaProperty<P> metaProperty) {
        return new BasicProperty<>(bean, metaProperty);
    }
381504
private Map<String, Object> writeBean(Bean bean, Class<?> declaredType) {
        Map<String, Object> result = new LinkedHashMap<>();
        // property information
        for (MetaProperty<?> prop : bean.metaBean().metaPropertyIterable()) {
            if (prop.style().isSerializable() || (prop.style().isDerived() && settings.isIncludeDerived())) {
                Object value = SerOptional.extractValue(prop, bean);
                if (value != null) {
                    Object outputValue = null;
                    Class<?> propType = SerOptional.extractType(prop, bean.getClass());
                    if (value instanceof Bean) {
                        if (settings.getConverter().isConvertible(value.getClass())) {
                            outputValue = writeSimple(propType, value);
                        } else {
                            outputValue = writeBean((Bean) value, propType);
                        }
                    } else {
                        SerIterator itemIterator = settings.getIteratorFactory().create(value, prop, bean.getClass(), true);
                        if (itemIterator != null) {
                            outputValue = writeElements(itemIterator);
                        } else {
                            outputValue = writeSimple(propType, value);
                        }
                    }
                    result.put(prop.name(), outputValue);
                }
            }
        }
        return result;
    }
880751
public <T> void setBeanProperty(final T bean, final Object property, final Object value) {
        if (bean != null) {
            @SuppressWarnings("unchecked")
            SetResolver<T> resolver = this.setters.unsafeGet(bean.getClass());
            if (resolver != null) {
                resolver.set(bean, property, value);
                return;
            }
        }
        this.resolverManager.set(bean, property, value);
    }
201833
List<String> generateMetaPropertyConstant() {
        data.getBean().ensureImport(MetaProperty.class);
        data.getBean().ensureImport(DirectMetaProperty.class);
        List<String> list = new ArrayList<>();
        list.add("\t\t/**");
        list.add("\t\t * The meta-property for the {@code " + data.getPropertyName() + "} property.");
        list.add("\t\t */");
        if (data.isBeanGenericType()) {
            list.add("\t\t@SuppressWarnings({\"unchecked\", \"rawtypes\" })");
            list.add("\t\tprivate final MetaProperty<" + propertyType() + "> " + data.getMetaFieldName() +
                " = (DirectMetaProperty) DirectMetaProperty.of" + readWrite() + "(");
            list.add("\t\t\t\tthis, \"" + data.getPropertyName() + "\", " +
                data.getBean().getTypeRaw() + ".class, " + actualType() + ");");
        } else {
            String propertyType = propertyType();
            if (propertyType.length() == 1) {
                propertyType = "Object";
            }
            if (data.isGenericParamType()) {
                list.add("\t\t@SuppressWarnings({\"unchecked\", \"rawtypes\" })");
            }
            list.add("\t\tprivate final MetaProperty<" + propertyType + "> " + data.getMetaFieldName() +
                " = DirectMetaProperty.of" + readWrite() + "(");
            list.add("\t\t\t\tthis, \"" + data.getPropertyName() + "\", " +
                data.getBean().getTypeRaw() + ".class, " + actualType() + ");");
        }
        return list;
    }
591666
private static PropertyDescriptor[] getPropertyDescriptors(Object bean)
   {
       if(bean == null)
           throw new IllegalArgumentException("No bean specified");
       else
           return getPropertyDescriptors(bean.getClass());
   }
111846
public static void set(final Object bean, final String property, Object value) {

        try {
            if (property.indexOf(".") >= 0) {

                final String firstProperty = property.substring(0, property.indexOf("."));
                Object subBean = ClassMockUtils.get(bean, firstProperty);

                if (subBean == null) {

                    subBean = ClassMockUtils.getPropertyClass(bean.getClass(), firstProperty).newInstance();
                    ClassMockUtils.set(bean, firstProperty, subBean);
                }

                final String newProperty = property.substring(property.indexOf(".") + 1);
                ClassMockUtils.set(subBean, newProperty, value);

                return;
            }

            Method setterMethod = null;

            for (final Method method : bean.getClass().getMethods()) {

                if (method.getName().equals(ClassMockUtils.propertyToSetter(property))) {

                    setterMethod = method;
                    break;
                }
            }

            if (setterMethod != null) {

                final Class<?> type = setterMethod.getParameterTypes()[0];

                if (type == null) {

                    throw new RuntimeException("The setter method of " + property + " does not have a parameter.");

                } else if (type.isArray() && !type.getComponentType().isPrimitive()) {

                    final Object[] array = (Object[]) Array.newInstance(type.getComponentType(), ((Object[]) value).length);

                    for (int i = 0; i < array.length; i++) {

                        array[i] = type.getComponentType().cast(((Object[]) value)[i]);
                    }

                    setterMethod.invoke(bean, new Object[] { array });

                } else {

                    if ((value instanceof String) && ((type == Integer.class) || (type == int.class))) {
                        value = Integer.parseInt((String) value);
                    } else if ((value instanceof String) && ((type == Long.class) || (type == long.class))) {
                        value = Long.parseLong((String) value);
                    } else if ((value instanceof String) && ((type == Byte.class) || (type == byte.class))) {
                        value = Byte.parseByte((String) value);
                    } else if ((value instanceof String) && ((type == Short.class) || (type == short.class))) {
                        value = Short.parseShort((String) value);
                    } else if ((value instanceof String) && ((type == Float.class) || (type == float.class))) {
                        value = Float.parseFloat((String) value);
                    } else if ((value instanceof String) && ((type == Double.class) || (type == double.class))) {
                        value = Double.parseDouble((String) value);
                    } else if ((value instanceof String) && ((type == Boolean.class) || (type == boolean.class))) {
                        value = Boolean.parseBoolean((String) value);
                    }

                    setterMethod.invoke(bean, value);
                }
            }
        } catch (final Exception e) {

            throw new RuntimeException("Can't set property " + property + " in the class " + bean.getClass().getName());
        }
    }
557261
public static final Object getValue(Object bean, String property)
    {
        return doFor(bean, property, null, BeanHelper::getValue, BeanHelper::getValue, BeanHelper::getFieldValue, BeanHelper::getMethodValue);
    }
211180
public static <T> T getProperty(Object bean, String name, Class<T> clazz) throws Exception {
        Method method = ReflectUtils.getPropertyGetterMethod(bean.getClass(), name);
        if (method.isAccessible()) {
            return (T) method.invoke(bean);
        } else {
            try {
                method.setAccessible(true);
                return (T) method.invoke(bean);
            } finally {
                method.setAccessible(false);
            }
        }
    }
845235
@SuppressWarnings("unchecked")
    static <P> MutableLightMetaProperty<P> of(
            MetaBean metaBean,
            final Field field,
            final String propertyName,
            int constructorIndex) {
        
        PropertyGetter getter = new PropertyGetter() {
            @Override
            public Object get(Bean bean) {
                try {
                    return field.get(bean);
                } catch (IllegalArgumentException | IllegalAccessException ex) {
                    throw new UnsupportedOperationException("Property cannot be read: " + propertyName, ex);
                }
            }
        };
        PropertySetter setter = new PropertySetter() {
            @Override
            public void set(Bean bean, Object value) {
                try {
                    field.set(bean, value);
                } catch (IllegalArgumentException | IllegalAccessException ex) {
                    throw new UnsupportedOperationException("Property cannot be read: " + propertyName, ex);
                }
            }
        };
        return new MutableLightMetaProperty<>(
                metaBean, 
                propertyName, 
                (Class<P>) field.getType(), 
                field.getGenericType(), 
                Arrays.asList(field.getAnnotations()), 
                getter,
                setter,
                constructorIndex);
    }
584534
public static <T extends ContentMeta> T withStream(InputStream source, Map<String, String> meta,
            ContentFactory<T> factory) {
        return factory.create(lazyStream(source), meta);
    }
199680
public static String[][] getProperties(final Bean bean) {
        final List<String> propertyNames = bean.getPropertyNames();
        final int psize = propertyNames.size();
        final String[][] properties = new String[psize][];
        for (int i = 0; i < psize; i++) {
            final String propertyName = propertyNames.get(i);
            final List<String> values = bean.getValues(propertyName);
            final int vsize = values.size();
            properties[i] = new String[vsize + 1];
            properties[i][0] = propertyName;
            for (int j = 0; j < vsize; j++) {
                properties[i][j + 1] = values.get(j);
            }
        }
        return properties;
    }
225573
public static Class<?> getPropertyClass(Class<?> beanClass, String field) {
		return INSTANCE.findPropertyClass(beanClass, field);
	}
518233
public static <Q> Object getPropertyValue(Q bean, String propertyName) {

        return ObjectUtils.getPropertyValue(bean, propertyName, Object.class);
    }
656769
public static Object getMappedProperty(Object bean, String name)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, Exception
    {
        if(bean == null)
            throw new IllegalArgumentException("No bean specified");
        if(name == null)
            throw new IllegalArgumentException("No name specified");
        int delim = name.indexOf('(');
        int delim2 = name.indexOf(')');
        if(delim < 0 || delim2 <= delim)
        {
            throw new IllegalArgumentException("Invalid mapped property '" + name + "'");
        } else
        {
            String key = name.substring(delim + 1, delim2);
            name = name.substring(0, delim);
            return getMappedProperty(bean, name, key);
        }
    }
290188
public static final <T extends Annotation> T getAnnotation(Object bean, String property, Class<T> annotationClass)
    {
        return (T) doFor(
            bean, 
            property, 
            null,
            (Object a, int i)->{Object o=Array.get(a, i);return o!=null?o.getClass().getAnnotation(annotationClass):null;},
            (List l, int i)->{return l.get(i).getClass().getAnnotation(annotationClass);},
            (Object b, Class c, String p)->{return getField(c, p).getAnnotation(annotationClass);}, 
            (Object b, Method m)->{return m.getAnnotation(annotationClass);});
    }
1190546
public <T> Object getBeanProperty(final T bean, final Object property) {
        if (bean != null) {
            @SuppressWarnings("unchecked")
            GetResolver<T> resolver = this.getters.unsafeGet(bean.getClass());
            if (resolver != null) {
                return resolver.get(bean, property);
            }
        }
        return this.resolverManager.get(bean, property);
    }
690492
public static Object getProperty(Object bean, String expression) {
		return BeanPath.create(expression).get(bean);
	}