Examples of PropertyDescriptor


Examples of java.beans.PropertyDescriptor

  @Test
  public void testPropertyValueSetter2() throws Exception
  {
    TestAction action = new TestAction();
    Method setterMethod = getSetter(action, "setIntegerInput", Integer.class);
    PropertyDescriptor descriptor = BeanUtils.findPropertyForMethod(setterMethod);

    PropertyValueSetter.setPropertyValue(action, descriptor, new Integer(1));
    assert action.getIntegerInput().equals(1);
  }
View Full Code Here

Examples of java.beans.PropertyDescriptor

        Type[] types = ((ParameterizedType)method.getGenericReturnType()).getActualTypeArguments();
        if(types.length == 1){
          try{
            Class<?> clazz = (Class<?>) types[0];
            PropertyDescriptor[]   props       = getBeanProperties(clazz);
                  PropertyDescriptor    keyProperty    = null;
                  PropertyDescriptor    valueProperty  = null;
                  for(PropertyDescriptor prop : props){
                    if(listMapKey.matcher(clazz.getName() + "." + prop.getName()).find()){
                      keyProperty = prop;
                      break;
                    }
                  }
                  if(listMapValue != null){
                    for(PropertyDescriptor prop : props){
                      if(listMapValue.matcher(clazz.getName() + "." + prop.getName()).find()){
                        valueProperty = prop;
                        break;
                      }
                    }
                  }
                  if(keyProperty != null){
                    Method keyReadMethod   = keyProperty.getReadMethod();
                    Method valueReadMethod   = valueProperty != null ? valueProperty.getReadMethod() : null;
                    HashMap<String,Object> map = new LinkedHashMap<String,Object>();
                    while(iterator.hasNext()){
                      Object ob = iterator.next();
                      map.put(String.valueOf(keyReadMethod.invoke(ob)), valueReadMethod != null ? valueReadMethod.invoke(ob) : ob);
                    }
View Full Code Here

Examples of java.beans.PropertyDescriptor

  /**
   * Gets getter corresponding with setter method
   */
  public static Method getGetter(Method setterMethod)
  {
    PropertyDescriptor property = BeanUtils.findPropertyForMethod(setterMethod);
    if (property == null)
    {
      return null;
    }
    else
    {
      return property.getReadMethod();
    }
  }
View Full Code Here

Examples of java.beans.PropertyDescriptor

  /**
   * Gets setter corresponding with getter method
   */
  public static Method getSetter(Method getterMethod)
  {
    PropertyDescriptor property = BeanUtils.findPropertyForMethod(getterMethod);
    if (property == null)
    {
      return null;
    }
    else
    {
      return property.getWriteMethod();
    }
  }
View Full Code Here

Examples of java.beans.PropertyDescriptor

  }

  public static boolean isGetter(Method method)
  {

    PropertyDescriptor property = BeanUtils.findPropertyForMethod(method);

    if (property == null)
      return false;

    return property.getReadMethod().equals(method);

  }
View Full Code Here

Examples of java.beans.PropertyDescriptor

  {
    Class<?> propertyType = null;
    try
    {

      PropertyDescriptor propertyDescriptor = PropertyUtils.getPropertyDescriptor(containingBean,
          beanPropertyName);
      propertyType = propertyDescriptor.getPropertyType();

    }
    catch (Exception e)
    {
      throw new ApplicationRuntimeException("Unable to read property descriptor for bean "
View Full Code Here

Examples of java.beans.PropertyDescriptor

  {

    Assert.notNull(containingBean);
    Assert.notNull(propertyName);

    PropertyDescriptor descriptor;
    try
    {
      // properties with bind annotation must be Strings
      descriptor = PropertyUtils.getPropertyDescriptor(containingBean, propertyName);
    }
View Full Code Here

Examples of java.beans.PropertyDescriptor

      Class<? extends Converter> converterClass = bindAnnotation.converter();
      converter = ReflectHelper.createInstance(converterClass, Converter.class);
      handler.setConverter(converter);
    }

    PropertyDescriptor property = BeanUtils.findPropertyForMethod(getterMethod);
    if (property == null)
    {
      throw new ApplicationConfigurationException("Method " + getterMethod + " is not a valid JavaBean property");
    }
    handler.setPropertyDescriptor(property);
View Full Code Here

Examples of java.beans.PropertyDescriptor

      converter = ReflectHelper.createInstance(converterClass, Converter.class);
      converter.setTargetClass(bindAnnotation.idClass());
      handler.setConverter(converter);
    }

    PropertyDescriptor property = BeanUtils.findPropertyForMethod(getterMethod);

    if (property == null)
    {
      throw new ApplicationConfigurationException("Method " + getterMethod + " is not a valid JavaBean property");
    }
View Full Code Here

Examples of java.beans.PropertyDescriptor

    Object hierarchyValue = parentObj;
    DeepHierarchyElement[] hierarchy = getDeepFieldHierarchy(srcObj, srcDeepIndexHintContainer);
    int size = hierarchy.length;
    for (int i = 0; i < size; i++) {
      DeepHierarchyElement hierarchyElement = hierarchy[i];
      PropertyDescriptor pd = hierarchyElement.getPropDescriptor();
      // If any fields in the deep hierarchy are indexed, get actual value within the collection at the specified index
      if (hierarchyElement.getIndex() > -1) {
        hierarchyValue = MappingUtils.getIndexedValue(ReflectionUtils.invoke(pd.getReadMethod(), hierarchyValue, null),
            hierarchyElement.getIndex());
      } else {
        hierarchyValue = ReflectionUtils.invoke(pd.getReadMethod(), parentObj, null);
      }
      parentObj = hierarchyValue;
      if (hierarchyValue == null) {
        break;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.