/** * Attempt to resolve the specified property type through reflection. * * @param clazz The class owning the property. * @param name The name of the property. * @return The type of the property. * @throws MappingException Indicates we were unable to locate the property. */ public static Class reflectedPropertyClass(Class clazz, String name) throws MappingException { return getter( clazz, name ).getReturnType(); }
@Override protected Class<?> executeForIntermediateField(String field, Class<?> result) { // get chained field class Getter getter = propertyAccessor.getGetter(result, field); return getter.getReturnType(); } }.resolve(alias, i);
/** * Attempt to resolve the specified property type through reflection. * * @param clazz The class owning the property. * @param name The name of the property. * @return The type of the property. * @throws MappingException Indicates we were unable to locate the property. */ public static Class reflectedPropertyClass(Class clazz, String name) throws MappingException { return getter( clazz, name ).getReturnType(); }
public boolean isPrimitive(Class clazz) { return getGetter(clazz).getReturnType().isPrimitive(); }
public boolean isPrimitive(Class clazz) { return getGetter(clazz).getReturnType().isPrimitive(); }
public boolean isPrimitive(Class clazz) { return getGetter(clazz).getReturnType().isPrimitive(); }
public boolean isPrimitive(Class clazz) { return getGetter(clazz).getReturnType().isPrimitive(); }
fieldName = property.substring(0, fieldIndex); getter = propertyAccessor.getGetter(clazz, fieldName); clazz = getter.getReturnType();
@Override protected Object executeForIntermediateField(String field, Object result) throws InstantiationException, IllegalAccessException { // set intermediate object association Getter getter = propertyAccessor.getGetter(result.getClass(), field); Setter setter = propertyAccessor.getSetter(result.getClass(), field); Object associate = getter.get(result); if (associate == null) { // there is no instance yet in referenced field associate = getter.getReturnType().newInstance(); } setter.set(result, associate, null); return associate; } }.resolve(alias, i);
public Query setProperties(Object bean) throws HibernateException { Class clazz = bean.getClass(); String[] params = getNamedParameters(); for (int i = 0; i < params.length; i++) { String namedParam = params[i]; try { Getter getter = ReflectHelper.getGetter( clazz, namedParam ); Class retType = getter.getReturnType(); final Object object = getter.get( bean ); if ( Collection.class.isAssignableFrom( retType ) ) { setParameterList( namedParam, ( Collection ) object ); } else if ( retType.isArray() ) { setParameterList( namedParam, ( Object[] ) object ); } else { setParameter( namedParam, object, determineType( namedParam, retType ) ); } } catch (PropertyNotFoundException pnfe) { // ignore } } return this; }
public static Class reflectedPropertyClass(String className, String name) throws MappingException { try { Class clazz = ReflectHelper.classForName(className); return getter(clazz, name).getReturnType(); } catch (ClassNotFoundException cnfe) { throw new MappingException("class " + className + " not found while looking for property: " + name, cnfe); } }
public static Class reflectedPropertyClass(String className, String name) throws MappingException { try { Class clazz = ReflectHelper.classForName(className); return getter(clazz, name).getReturnType(); } catch (ClassNotFoundException cnfe) { throw new MappingException("class " + className + " not found while looking for property: " + name, cnfe); } }
public Query setProperties(Object bean) throws HibernateException { Class clazz = bean.getClass(); String[] params = getNamedParameters(); for (int i = 0; i < params.length; i++) { String namedParam = params[i]; try { Getter getter = ReflectHelper.getGetter(clazz, namedParam); Class retType = getter.getReturnType(); final Object object = getter.get( bean ); if ( Collection.class.isAssignableFrom(retType) ) { setParameterList( namedParam, (Collection) object ); } else if ( retType.isArray() ) { setParameterList( namedParam, (Object[]) object ); } else { setParameter( namedParam, object, guessType( getter.getReturnType() ) ); } } catch (PropertyNotFoundException pnfe) {} } return this; }
/** * Attempt to resolve the specified property type through reflection. * * @param className The name of the class owning the property. * @param name The name of the property. * @return The type of the property. * @throws MappingException Indicates we were unable to locate the property. */ public static Class reflectedPropertyClass(String className, String name) throws MappingException { try { Class clazz = ReflectHelper.classForName( className ); return getter( clazz, name ).getReturnType(); } catch ( ClassNotFoundException cnfe ) { throw new MappingException( "class " + className + " not found while looking for property: " + name, cnfe ); } }
/** * Attempt to resolve the specified property type through reflection. * * @param className The name of the class owning the property. * @param name The name of the property. * @return The type of the property. * @throws MappingException Indicates we were unable to locate the property. */ public static Class reflectedPropertyClass(String className, String name) throws MappingException { try { Class clazz = ReflectHelper.classForName( className ); return getter( clazz, name ).getReturnType(); } catch ( ClassNotFoundException cnfe ) { throw new MappingException( "class " + className + " not found while looking for property: " + name, cnfe ); } }
public Query setProperties(Object bean) throws HibernateException { Class clazz = bean.getClass(); String[] params = getNamedParameters(); for (int i = 0; i < params.length; i++) { String namedParam = params[i]; try { Getter getter = ReflectHelper.getGetter( clazz, namedParam ); Class retType = getter.getReturnType(); final Object object = getter.get( bean ); if ( Collection.class.isAssignableFrom( retType ) ) { setParameterList( namedParam, ( Collection ) object ); } else if ( retType.isArray() ) { setParameterList( namedParam, ( Object[] ) object ); } else { setParameter( namedParam, object, determineType( namedParam, retType ) ); } } catch (PropertyNotFoundException pnfe) { // ignore } } return this; }
public Query setProperties(Object bean) throws HibernateException { Class clazz = bean.getClass(); String[] params = getNamedParameters(); for (int i = 0; i < params.length; i++) { String namedParam = params[i]; try { Getter getter = ReflectHelper.getGetter( clazz, namedParam ); Class retType = getter.getReturnType(); final Object object = getter.get( bean ); if ( Collection.class.isAssignableFrom( retType ) ) { setParameterList( namedParam, ( Collection ) object ); } else if ( retType.isArray() ) { setParameterList( namedParam, ( Object[] ) object ); } else { setParameter( namedParam, object, determineType( namedParam, retType ) ); } } catch (PropertyNotFoundException pnfe) { // ignore } } return this; }
@SuppressWarnings( "unchecked" ) private void addSubElement(Property property, ValidatableElement element) { if ( property != null && property.isComposite() && !property.isBackRef() ) { Component component = (Component) property.getValue(); if ( component.isEmbedded() ) return; PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.POJO ); Getter getter = accessor.getGetter( element.clazz, property.getName() ); ClassValidator validator = new ClassValidator( getter.getReturnType() ); ValidatableElement subElement = new ValidatableElement( getter.getReturnType(), validator, getter ); Iterator properties = component.getPropertyIterator(); while ( properties.hasNext() ) { addSubElement( (Property) properties.next(), subElement ); } if ( subElement.getSubElements().size() != 0 || subElement.validator.hasValidationRules() ) { element.addSubElement( subElement ); } } }
protected AbstractComponentTuplizer(Component component) { propertySpan = component.getPropertySpan(); getters = new Getter[propertySpan]; setters = new Setter[propertySpan]; Iterator iter = component.getPropertyIterator(); boolean foundCustomAccessor=false; int i=0; while ( iter.hasNext() ) { Property prop = (Property) iter.next(); getters[i] = buildGetter(component, prop); setters[i] = buildSetter(component, prop); if ( !prop.isBasicPropertyAccessor() ) foundCustomAccessor = true; i++; } hasCustomAccessors = foundCustomAccessor; String[] getterNames = new String[propertySpan]; String[] setterNames = new String[propertySpan]; Class[] propTypes = new Class[propertySpan]; for ( int j = 0; j < propertySpan; j++ ) { getterNames[j] = getters[j].getMethodName(); setterNames[j] = setters[j].getMethodName(); propTypes[j] = getters[j].getReturnType(); } instantiator = buildInstantiator(component); }
@Ignore("need to convert, was originally written for the old value holder design (TextString, etc)") @Test public void happyCase() { obj.setString(expected); NakedPropertyAccessor accessor = new NakedPropertyAccessor(); Getter getter = accessor.getGetter(SimpleObject.class, "string"); assertNotNull(getter); assertNull("getMethod", getter.getMethod()); assertNull("getMethodName", getter.getMethodName()); assertEquals("return type", String.class, getter.getReturnType()); }