Package java.beans

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


  {
    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

  {

    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

      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

      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

    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

        // If destination field does not have a write method, then skip
        if (destPropertyDescriptor.getWriteMethod() == null) {
          continue;
        }

        PropertyDescriptor srcProperty = ReflectionUtils.findPropertyDescriptor(srcClass, fieldName, null);

        // If the sourceProperty is null we know that there is not a corresponding property to map to.
        // If source property does not have a read method, then skip
        if (srcProperty == null || srcProperty.getReadMethod() == null) {
          continue;
        }

        addGenericMapping(classMap, configuration, fieldName, fieldName);
      }
View Full Code Here

  @Test
  public void testFindPropertyDescriptor_InterfaceInheritance() throws Exception {
    // Should walk the inheritance hierarchy all the way up to the super interface and find the property along the way
    String fieldName = "parentField";

    PropertyDescriptor pd = ReflectionUtils.findPropertyDescriptor(ChildChildIF.class, fieldName, null);

    assertNotNull("prop descriptor should not be null", pd);
    assertEquals("invalid prop descriptor name found", fieldName, pd.getName());
  }
View Full Code Here

  }

  @Test
  public void shouldReturnBestMatch_ambigousIgonreCase() {
    // both timezone and timeZone properties exists on XMLGregorianCalendar
    PropertyDescriptor result = ReflectionUtils.findPropertyDescriptor(XMLGregorianCalendar.class, "timezone", null);
   
    assertThat(result.getName(), equalTo("timezone"));
  }
View Full Code Here

  private static final String IAE_MESSAGE = "argument type mismatch";

  private ReflectionUtils() {}

  public static PropertyDescriptor findPropertyDescriptor(Class<?> objectClass, String fieldName, HintContainer deepIndexHintContainer) {
    PropertyDescriptor result = null;
    if (MappingUtils.isDeepMapping(fieldName)) {
      DeepHierarchyElement[] hierarchy = getDeepFieldHierarchy(objectClass, fieldName, deepIndexHintContainer);
      result = hierarchy[hierarchy.length - 1].getPropDescriptor();
    } else {
      PropertyDescriptor[] descriptors = getPropertyDescriptors(objectClass);
View Full Code Here

TOP

Related Classes of java.beans.PropertyDescriptor

Copyright © 2018 www.massapicom. 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.