Package br.net.woodstock.rockframework.reflection

Examples of br.net.woodstock.rockframework.reflection.PropertyDescriptor


    for (Method method : c.getMethods()) {
      if (BeanDescriptorHelper.isValidGetterOrSetter(method)) {
        String propertyName = BeanDescriptorHelper.getPropertyName(method);
        if (!this.hasProperty(propertyName)) {
          Class<?> propertyType = BeanDescriptorHelper.getPropertyType(method);
          PropertyDescriptor property = new MethodPropertyDescriptor(this, propertyName, propertyType);
          if ((property.isReadable()) || (property.isWriteable())) {
            this.getProperties().add(property);
          }
        }
      }
    }
View Full Code Here


    BeanDescriptor beanDescriptorFrom = new BeanDescriptorBuilder(from.getClass()).getBeanDescriptor();
    BeanDescriptor beanDescriptorTo = new BeanDescriptorBuilder(to.getClass()).getBeanDescriptor();

    outer: for (PropertyDescriptor propertyDescriptor : beanDescriptorFrom.getProperties()) {
      if (beanDescriptorTo.hasProperty(propertyDescriptor.getName())) {
        PropertyDescriptor propertyDescriptorTo = beanDescriptorTo.getProperty(propertyDescriptor.getName());
        if (ignoredTypes != null) {
          for (Class<?> c : ignoredTypes) {
            if ((c.isAssignableFrom(propertyDescriptor.getType())) || (c.isAssignableFrom(propertyDescriptorTo.getType()))) {
              continue outer;
            }
          }
        }
        if (!propertyDescriptorTo.getType().isAssignableFrom(propertyDescriptor.getType())) {
          continue;
        }
        Object tmp = propertyDescriptor.getValue(from);
        propertyDescriptorTo.setValue(to, tmp);
      }
    }
  }
View Full Code Here

    BeanDescriptor beanDescriptorFrom = new BeanDescriptorBuilder(from.getClass()).getBeanDescriptor();
    BeanDescriptor beanDescriptorTo = new BeanDescriptorBuilder(to.getClass()).getBeanDescriptor();

    outer: for (PropertyDescriptor propertyDescriptor : beanDescriptorFrom.getProperties()) {
      if (beanDescriptorTo.hasProperty(propertyDescriptor.getName())) {
        PropertyDescriptor propertyDescriptorTo = beanDescriptorTo.getProperty(propertyDescriptor.getName());
        if (ignoredAttributes != null) {
          for (String s : ignoredAttributes) {
            if (s.equals(propertyDescriptor.getName())) {
              continue outer;
            }
          }
        }
        if (!propertyDescriptorTo.getType().isAssignableFrom(propertyDescriptor.getType())) {
          continue;
        }
        Object tmp = propertyDescriptor.getValue(from);
        propertyDescriptorTo.setValue(to, tmp);
      }
    }
  }
View Full Code Here

      if ((obj != null) && (obj instanceof Entity)) {
        Entity<?> entity = (Entity<?>) obj;

        BeanDescriptor beanDescriptor = new BeanDescriptorBuilder(entity.getClass()).getBeanDescriptor();

        PropertyDescriptor propertyDescriptor = beanDescriptor.getProperty(EntityInterceptor.ENTITY_ID);
        Class<?> clazz = propertyDescriptor.getType();

        try {
          Constructor<?> contructor = clazz.getConstructor(new Class[] { String.class });
          Object fieldValue = contructor.newInstance(new Object[] { value });

          WebLog.getInstance().getLog().info("Setting entity ID " + entityName + "[" + fieldValue + "]");
          propertyDescriptor.setValue(entity, fieldValue);
        } catch (NoSuchMethodException e) {
          WebLog.getInstance().getLog().warning("Could not find constructor " + entity.getClass().getCanonicalName() + "(String). Parameter not setted");
        } catch (Exception e) {
          WebLog.getInstance().getLog().warning("Error in constructor " + entity.getClass().getCanonicalName() + "(String)");
          WebLog.getInstance().getLog().log(Level.WARNING, e.getMessage(), e);
View Full Code Here

      if ((obj != null) && (obj instanceof Entity)) {
        Entity<?> entity = (Entity<?>) obj;

        BeanDescriptor beanDescriptor = new BeanDescriptorBuilder(entity.getClass()).getBeanDescriptor();

        PropertyDescriptor propertyDescriptor = beanDescriptor.getProperty(EntityInterceptor.ENTITY_ID);
        Class<?> clazz = propertyDescriptor.getType();

        try {
          Constructor<?> contructor = clazz.getConstructor(new Class[] { String.class });
          Object fieldValue = contructor.newInstance(new Object[] { value });

          WebLog.getInstance().getLog().info("Setting entity ID " + entityName + "[" + fieldValue + "]");
          propertyDescriptor.setValue(entity, fieldValue);
        } catch (NoSuchMethodException e) {
          WebLog.getInstance().getLog().warn("Could not find constructor " + entity.getClass().getCanonicalName() + "(String). Parameter not setted");
        } catch (Exception e) {
          WebLog.getInstance().getLog().warn("Error in constructor " + entity.getClass().getCanonicalName() + "(String)");
          WebLog.getInstance().getLog().warn(e.getMessage(), e);
View Full Code Here

      if ((obj != null) && (obj instanceof Entity)) {
        Entity<?> entity = (Entity<?>) obj;

        BeanDescriptor beanDescriptor = new BeanDescriptorBuilder(entity.getClass()).getBeanDescriptor();

        PropertyDescriptor propertyDescriptor = beanDescriptor.getProperty(EntityInterceptor.ENTITY_ID);
        Class<?> clazz = propertyDescriptor.getType();

        try {
          Constructor<?> contructor = clazz.getConstructor(new Class[] { String.class });
          Object fieldValue = contructor.newInstance(new Object[] { value });

          WebLog.getInstance().getLogger().info("Setting entity ID " + entityName + "[" + fieldValue + "]");
          propertyDescriptor.setValue(entity, fieldValue);
        } catch (NoSuchMethodException e) {
          WebLog.getInstance().getLogger().warn("Could not find constructor " + entity.getClass().getCanonicalName() + "(String). Parameter not setted");
        } catch (Exception e) {
          WebLog.getInstance().getLogger().warn("Error in constructor " + entity.getClass().getCanonicalName() + "(String)");
          WebLog.getInstance().getLogger().warn(e.getMessage(), e);
View Full Code Here

      if ((obj != null) && (obj instanceof Entity)) {
        Entity<?> entity = (Entity<?>) obj;

        BeanDescriptor beanDescriptor = new BeanDescriptorBuilder(entity.getClass()).getBeanDescriptor();

        PropertyDescriptor propertyDescriptor = beanDescriptor.getProperty(EntityInterceptor.ENTITY_ID);
        Class<?> clazz = propertyDescriptor.getType();

        try {
          Constructor<?> contructor = clazz.getConstructor(new Class[] { String.class });
          Object fieldValue = contructor.newInstance(new Object[] { value });

          WebLog.getInstance().getLogger().info("Setting entity ID " + entityName + "[" + fieldValue + "]");
          propertyDescriptor.setValue(entity, fieldValue);
        } catch (NoSuchMethodException e) {
          WebLog.getInstance().getLogger().warn("Could not find constructor " + entity.getClass().getCanonicalName() + "(String). Parameter not setted");
        } catch (Exception e) {
          WebLog.getInstance().getLogger().warn("Error in constructor " + entity.getClass().getCanonicalName() + "(String)");
          WebLog.getInstance().getLogger().warn(e.getMessage(), e);
View Full Code Here

      if ((obj != null) && (obj instanceof Entity)) {
        Entity<?> entity = (Entity<?>) obj;

        BeanDescriptor beanDescriptor = new BeanDescriptorBuilder(entity.getClass()).getBeanDescriptor();

        PropertyDescriptor propertyDescriptor = beanDescriptor.getProperty(EntityInterceptor.ENTITY_ID);
        Class<?> clazz = propertyDescriptor.getType();

        try {
          Constructor<?> contructor = clazz.getConstructor(new Class[] { String.class });
          Object fieldValue = contructor.newInstance(new Object[] { value });

          WebLog.getInstance().getLog().info("Setting entity ID " + entityName + "[" + fieldValue + "]");
          propertyDescriptor.setValue(entity, fieldValue);
        } catch (NoSuchMethodException e) {
          WebLog.getInstance().getLog().warn("Could not find constructor " + entity.getClass().getCanonicalName() + "(String). Parameter not setted");
        } catch (Exception e) {
          WebLog.getInstance().getLog().warn("Error in constructor " + entity.getClass().getCanonicalName() + "(String)");
          WebLog.getInstance().getLog().warn(e.getMessage(), e);
View Full Code Here

    for (Method method : c.getMethods()) {
      if (BeanDescriptorHelper.isValidGetterOrSetter(method)) {
        String propertyName = BeanDescriptorHelper.getPropertyName(method);
        if (!this.hasProperty(propertyName)) {
          Class<?> propertyType = BeanDescriptorHelper.getPropertyType(method);
          PropertyDescriptor property = new MethodPropertyDescriptor(this, propertyName, propertyType);
          if ((property.isReadable()) || (property.isWriteable())) {
            this.getProperties().add(property);
          }
        }
      }
    }
View Full Code Here

    BeanDescriptor beanDescriptorFrom = new BeanDescriptorBuilder(from.getClass()).getBeanDescriptor();
    BeanDescriptor beanDescriptorTo = new BeanDescriptorBuilder(to.getClass()).getBeanDescriptor();

    outer: for (PropertyDescriptor propertyDescriptor : beanDescriptorFrom.getProperties()) {
      if (beanDescriptorTo.hasProperty(propertyDescriptor.getName())) {
        PropertyDescriptor propertyDescriptorTo = beanDescriptorTo.getProperty(propertyDescriptor.getName());
        if (ignoredTypes != null) {
          for (Class<?> c : ignoredTypes) {
            if ((c.isAssignableFrom(propertyDescriptor.getType())) || (c.isAssignableFrom(propertyDescriptorTo.getType()))) {
              continue outer;
            }
          }
        }
        if (!propertyDescriptorTo.getType().isAssignableFrom(propertyDescriptor.getType())) {
          continue;
        }
        Object tmp = propertyDescriptor.getValue(from);
        propertyDescriptorTo.setValue(to, tmp);
      }
    }
  }
View Full Code Here

TOP

Related Classes of br.net.woodstock.rockframework.reflection.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.