Package jfun.util.beans

Examples of jfun.util.beans.BeanType


   * @param bean the bean object.
   * @param name the property name.
   * @return the Function object.
   */
  public static Function setter(Bean bean, String name){
    final BeanType btype = bean.getBeanType();
    if(btype.getWriter(name) == null
        && btype.getIndexedWriter(name)==null){
      throw new IllegalArgumentException("property setter for "+
        bean.getBeanType().getType().getName()+"."+name+" not found.");
    }
    else
      return new PropertyWriter(bean, name);
View Full Code Here


   * @return the instance.
   * @throws IntrospectionException
   */
  public static PropertiesInjector instance(Class type)
  throws IntrospectionException{
    final BeanType bt =jfun.yan.util.Utils.toBeanType(type);
    return new DefaultPropertiesInjector(bt, null);
  }
View Full Code Here

   * @return the new component that handles property setting.
   * @throws IntrospectionException
   */
  public static PropertiesInjector instance(final Class type, final java.util.Set props)
  throws IntrospectionException{
    final BeanType bt = jfun.yan.util.Utils.toBeanType(type);
    checkIncludes(bt, props);
    return new DefaultPropertiesInjector(bt, props);
  }
View Full Code Here

    if(obj==null){
      throw new NullBeanObjectException("null component");
    }
    //dynamically resolve bean type and properties if necessary.
    final Class objtype = obj.getClass();
    final BeanType btype = obtainBeanType(objtype);
    final Set props = getProperties(btype);
    jfun.yan.util.Utils.injectProperties(btype, obj, props, dep);
  }
View Full Code Here

  }

  public void verifyProperties(Class type, Dependency dep){
    //dynamically resolve bean type and properties if necessary.
    //the type cannot be null now.
    final BeanType btype = obtainBeanType(type);
    final Set props = getProperties(btype);
    jfun.yan.util.Utils.verifyProperties(btype, props, dep);
  }
View Full Code Here

   * @throws IntrospectionException
   */
  public static PropertiesInjector instance(Class type,
      Class<? extends Annotation> annotation)
  throws IntrospectionException{
    final BeanType bt = Utils.toBeanType(type);
    return new AnnotationFilteredPropertiesInjector(bt, annotation);
  }
View Full Code Here

   * @param type the type.
   * @return this object.
   */
  public TypeFilteredPropertyPredicate addType(Class type){
    try{
      final BeanType btype = BeanType.instance(type);
      final Set names = btype.getPropertyNames();
      for(Iterator it=names.iterator();it.hasNext();){
        final String key = (String)it.next();
        final Method writer = btype.getWriter(key);
        if(writer!=null){
          addProperty(writer.getDeclaringClass(), key);
        }
      }
    }
View Full Code Here

    final Class type = c.getType();
    if(type==null){
      //unknown type, do not set property.
      return null;
    }
    final BeanType beantype = BeanType.instance(type);
    final PropertyDescriptor prop = beantype.getPropertyDescriptor(name);
    if(prop == null) return null;
    final Method mtd = prop.getWriteMethod();
    return mtd;
  }
View Full Code Here

   * @throws NonReadablePropertyException if the property is not rreadable.
   */
  public static Component getter(Class type, Object obj, String prop)
  throws IntrospectionException, NoSuchPropertyException,
  NonReadablePropertyException{
    final BeanType btype = BeanType.instance(type);
    final Method m = btype.getReader(prop);
    if(m==null)
      throw new NonReadablePropertyException(type, prop);
    return fun(Functions.getter(Bean.instance(type, obj), prop));
  }
View Full Code Here

   * @throws NonWritablePropertyException if the property is not writable.
   */
  public static <T> Component<T> setter(Class type, T obj, String prop)
  throws IntrospectionException, NoSuchPropertyException,
  NonWritablePropertyException{
    final BeanType btype = BeanType.instance(type);
    if(btype.getWriter(prop)==null && btype.getIndexedWriter(prop)==null)
      throw new NonWritablePropertyException(type, prop);
    return fun(Functions.setter(Bean.instance(type, obj), prop));
  }
View Full Code Here

TOP

Related Classes of jfun.util.beans.BeanType

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.