List of usage examples for java.beans PropertyDescriptor getPropertyType
public synchronized Class<?> getPropertyType()
From source file:org.kordamp.ezmorph.bean.BeanMorpher.java
public Object morph(Object sourceBean) { if (sourceBean == null) { return null; }//from w w w .jav a 2s .com if (!supports(sourceBean.getClass())) { throw new MorphException("unsupported class: " + sourceBean.getClass().getName()); } Object targetBean = null; try { targetBean = beanClass.newInstance(); PropertyDescriptor[] targetPds = PropertyUtils.getPropertyDescriptors(beanClass); for (int i = 0; i < targetPds.length; i++) { PropertyDescriptor targetPd = targetPds[i]; String name = targetPd.getName(); if (targetPd.getWriteMethod() == null) { log.info("Property '" + beanClass.getName() + "." + name + "' has no write method. SKIPPED."); continue; } Class sourceType = null; if (sourceBean instanceof DynaBean) { DynaBean dynaBean = (DynaBean) sourceBean; DynaProperty dynaProperty = dynaBean.getDynaClass().getDynaProperty(name); if (dynaProperty == null) { log.warn("DynaProperty '" + name + "' does not exist. SKIPPED."); continue; } sourceType = dynaProperty.getType(); } else { PropertyDescriptor sourcePd = PropertyUtils.getPropertyDescriptor(sourceBean, name); if (sourcePd == null) { log.warn("Property '" + sourceBean.getClass().getName() + "." + name + "' does not exist. SKIPPED."); continue; } else if (sourcePd.getReadMethod() == null) { log.warn("Property '" + sourceBean.getClass().getName() + "." + name + "' has no read method. SKIPPED."); continue; } sourceType = sourcePd.getPropertyType(); } Class targetType = targetPd.getPropertyType(); Object value = PropertyUtils.getProperty(sourceBean, name); setProperty(targetBean, name, sourceType, targetType, value); } } catch (MorphException me) { throw me; } catch (Exception e) { throw new MorphException(e); } return targetBean; }
From source file:com.interface21.beans.BeanWrapperImpl.java
public void doRegisterCustomEditor(Class requiredType, String propertyName, PropertyEditor propertyEditor) { if (this.customEditors == null) { this.customEditors = new HashMap(); }//w ww . java 2 s . c om if (propertyName != null) { // consistency check PropertyDescriptor descriptor = getPropertyDescriptor(propertyName); if (requiredType != null && !descriptor.getPropertyType().isAssignableFrom(requiredType)) { throw new IllegalArgumentException("Types do not match: required=" + requiredType.getName() + ", found=" + descriptor.getPropertyType()); } this.customEditors.put(propertyName, propertyEditor); } else { if (requiredType == null) { throw new IllegalArgumentException("No propertyName and no requiredType specified"); } this.customEditors.put(requiredType, propertyEditor); } }
From source file:org.tylproject.vaadin.addon.MongoContainer.java
MongoContainer(Builder<Bean> bldr) { this.criteria = bldr.mongoCriteria; this.baseSort = bldr.sort; this.filterConverter = bldr.filterConverter; this.baseQuery = Query.query(criteria).with(baseSort); resetQuery();//from w ww . jav a 2 s .c o m this.mongoOps = bldr.mongoOps; this.beanClass = bldr.beanClass; this.beanFactory = bldr.beanFactory; if (bldr.hasCustomPropertyList) { this.simpleProperties = Collections.unmodifiableMap(bldr.simpleProperties); } else { // otherwise, get them via reflection this.simpleProperties = new LinkedHashMap<String, Class<?>>(); PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(beanClass); for (PropertyDescriptor d : descriptors) { this.simpleProperties.put(d.getName(), d.getPropertyType()); } } if (bldr.hasNestedPropertyList) { this.nestedProperties = Collections.unmodifiableMap(bldr.nestedProperties); } else { nestedProperties = Collections.emptyMap(); } List<Object> allProps = new ArrayList<Object>(simpleProperties.keySet()); // remove "class" pseudo-property for compliance with BeanItem allProps.remove("class"); this.allProperties = Collections.unmodifiableList(allProps); allProps.addAll(nestedProperties.keySet()); this.pageSize = bldr.pageSize; }
From source file:org.gbif.portal.registration.UDDIUtils.java
/** * Updates the resource given, which must have the UUID set or it'll be a create * TODO Fill in the rest of the details/* www . j a va 2 s . c om*/ * @param resource To update * @param businessKey To update * @throws TransportException On uddi communication error - e.g. server down * @throws UDDIException On uddi communication error - e.g. bad data */ @SuppressWarnings("unchecked") public void updateResource(ResourceDetail resource, String businessKey) throws UDDIException, TransportException { BusinessService bs = new BusinessService(); bs.setBusinessKey(businessKey); bs.setServiceKey(resource.getServiceKey()); bs.setDefaultDescriptionString(resource.getDescription()); bs.setDefaultNameString(resource.getName(), "en"); bs.setDefaultName(new Name(resource.getName())); AuthToken authToken = uddiProxy.get_authToken(getUddiAuthUser(), getUddiAuthPassword()); //create business service vector Vector businessServiceVector = new Vector(); businessServiceVector.add(bs); //add other properties into a category bag CategoryBag cb = new CategoryBag(); try { Map<String, Object> properties = BeanUtils.describe(resource); for (String key : properties.keySet()) { Object property = properties.get(key); PropertyDescriptor pd = org.springframework.beans.BeanUtils .getPropertyDescriptor(ResourceDetail.class, key); Class propertyType = pd.getPropertyType(); if (property != null) { if (property instanceof List) { List propertyList = (List) property; for (Object listItem : propertyList) { if (listItem != null) addToCategoryBagIfNotNull(cb, key, listItem.toString()); } } else if (propertyType.equals(Date.class)) { SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy"); Method readMethod = pd.getReadMethod(); Date theDate = (Date) readMethod.invoke(resource, (Object[]) null); if (theDate != null) { addToCategoryBagIfNotNull(cb, key, sdf.format(theDate)); } } else { addToCategoryBagIfNotNull(cb, key, property.toString()); } } } } catch (Exception e) { logger.error(e.getMessage(), e); } bs.setCategoryBag(cb); logger.info("About to save..."); ServiceDetail sd = getUddiProxy().save_service(authToken.getAuthInfoString(), businessServiceVector); // set in the resource serviceKey if required Vector<BusinessService> resultVector = sd.getBusinessServiceVector(); AccessPoint ap = null; BindingTemplate bt = null; BindingTemplates bts = null; for (BusinessService rbs : resultVector) { logger.info("Setting the service key (should be once): " + rbs.getServiceKey()); resource.setServiceKey(rbs.getServiceKey()); bts = rbs.getBindingTemplates(); if (bts != null && bts.size() > 0) { bt = rbs.getBindingTemplates().get(0); ap = bt.getAccessPoint(); } break; } //if there are no binding templates, then add them if (bts == null || bts.size() == 0) { // Saving TModel TModelDetail tModelDetail = null; TModelList tModelList = getUddiProxy().find_tModel(resource.getResourceType(), null, null, null, 1); if (tModelList.getTModelInfos().size() == 0) { //save this new tmodel Vector tModels = new Vector(); TModel newTModel = new TModel("", resource.getResourceType()); tModels.add(newTModel); tModelDetail = getUddiProxy().save_tModel(authToken.getAuthInfoString(), tModels); } else { TModelInfo tModelInfo = tModelList.getTModelInfos().get(0); tModelDetail = getUddiProxy().get_tModelDetail(tModelInfo.getTModelKey()); } // Creating TModelInstanceDetails Vector tModelVector = tModelDetail.getTModelVector(); String tModelKey = ((TModel) (tModelVector.elementAt(0))).getTModelKey(); Vector tModelInstanceInfoVector = new Vector(); TModelInstanceInfo tModelInstanceInfo = new TModelInstanceInfo(tModelKey); tModelInstanceInfoVector.add(tModelInstanceInfo); TModelInstanceDetails tModelInstanceDetails = new TModelInstanceDetails(); tModelInstanceDetails.setTModelInstanceInfoVector(tModelInstanceInfoVector); Vector bindingTemplatesVector = new Vector(); // Create a new binding templates using required elements constructor // BindingKey must be "" to save a new binding BindingTemplate bindingTemplate = new BindingTemplate("", tModelInstanceDetails, new AccessPoint(resource.getAccessPoint(), "http")); bindingTemplate.setServiceKey(resource.getServiceKey()); bindingTemplatesVector.addElement(bindingTemplate); // **** Save the Binding Template BindingDetail bindingDetail = getUddiProxy().save_binding(authToken.getAuthInfoString(), bindingTemplatesVector); } logger.info("Save completed for " + resource.getName()); }
From source file:net.yasion.common.core.bean.wrapper.CachedIntrospectionResults.java
/** * Create a new CachedIntrospectionResults instance for the given class. * // ww w .jav a2s. c o m * @param beanClass * the bean class to analyze * @throws BeansException * in case of introspection failure */ private CachedIntrospectionResults(Class<?> beanClass) throws BeansException { try { if (logger.isTraceEnabled()) { logger.trace("Getting BeanInfo for class [" + beanClass.getName() + "]"); } BeanInfo beanInfo = null; for (BeanInfoFactory beanInfoFactory : beanInfoFactories) { beanInfo = beanInfoFactory.getBeanInfo(beanClass); if (beanInfo != null) { break; } } if (beanInfo == null) { // If none of the factories supported the class, fall back to the default beanInfo = (shouldIntrospectorIgnoreBeaninfoClasses ? Introspector.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO) : Introspector.getBeanInfo(beanClass)); } this.beanInfo = beanInfo; if (logger.isTraceEnabled()) { logger.trace("Caching PropertyDescriptors for class [" + beanClass.getName() + "]"); } this.propertyDescriptorCache = new LinkedHashMap<String, PropertyDescriptor>(); // This call is slow so we do it once. PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors(); for (PropertyDescriptor pd : pds) { if (Class.class.equals(beanClass) && ("classLoader".equals(pd.getName()) || "protectionDomain".equals(pd.getName()))) { // Ignore Class.getClassLoader() and getProtectionDomain() methods - nobody needs to bind to those continue; } if (logger.isTraceEnabled()) { logger.trace("Found bean property '" + pd.getName() + "'" + (pd.getPropertyType() != null ? " of type [" + pd.getPropertyType().getName() + "]" : "") + (pd.getPropertyEditorClass() != null ? "; editor [" + pd.getPropertyEditorClass().getName() + "]" : "")); } pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd); this.propertyDescriptorCache.put(pd.getName(), pd); } this.typeDescriptorCache = new ConcurrentReferenceHashMap<PropertyDescriptor, TypeDescriptor>(); } catch (IntrospectionException ex) { throw new FatalBeanException("Failed to obtain BeanInfo for class [" + beanClass.getName() + "]", ex); } }
From source file:org.kuali.ole.sec.businessobject.lookup.AccessSecurityBalanceLookupableHelperServiceImpl.java
/** * @param element//w w w .j a va 2 s.co m * @param attributeName * @return Column */ protected Column setupResultsColumn(BusinessObject element, String attributeName, BusinessObjectRestrictions businessObjectRestrictions) { Column col = new Column(); col.setPropertyName(attributeName); String columnTitle = getDataDictionaryService().getAttributeLabel(getBusinessObjectClass(), attributeName); if (StringUtils.isBlank(columnTitle)) { columnTitle = getDataDictionaryService().getCollectionLabel(getBusinessObjectClass(), attributeName); } col.setColumnTitle(columnTitle); col.setMaxLength(getDataDictionaryService().getAttributeMaxLength(getBusinessObjectClass(), attributeName)); Class formatterClass = getDataDictionaryService().getAttributeFormatter(getBusinessObjectClass(), attributeName); Formatter formatter = null; if (formatterClass != null) { try { formatter = (Formatter) formatterClass.newInstance(); col.setFormatter(formatter); } catch (InstantiationException e) { throw new RuntimeException( "Unable to get new instance of formatter class: " + formatterClass.getName()); } catch (IllegalAccessException e) { throw new RuntimeException( "Unable to get new instance of formatter class: " + formatterClass.getName()); } } // pick off result column from result list, do formatting String propValue = OLEConstants.EMPTY_STRING; Object prop = ObjectUtils.getPropertyValue(element, attributeName); // set comparator and formatter based on property type Class propClass = null; try { PropertyDescriptor propDescriptor = PropertyUtils.getPropertyDescriptor(element, col.getPropertyName()); if (propDescriptor != null) { propClass = propDescriptor.getPropertyType(); } } catch (Exception e) { throw new RuntimeException("Cannot access PropertyType for property " + "'" + col.getPropertyName() + "' " + " on an instance of '" + element.getClass().getName() + "'.", e); } // formatters if (prop != null) { // for Booleans, always use BooleanFormatter if (prop instanceof Boolean) { formatter = new BooleanFormatter(); } if (formatter != null) { propValue = (String) formatter.format(prop); } else { propValue = prop.toString(); } } // comparator col.setComparator(CellComparatorHelper.getAppropriateComparatorForPropertyClass(propClass)); col.setValueComparator(CellComparatorHelper.getAppropriateValueComparatorForPropertyClass(propClass)); propValue = maskValueIfNecessary(element.getClass(), col.getPropertyName(), propValue, businessObjectRestrictions); col.setPropertyValue(propValue); if (StringUtils.isNotBlank(propValue)) { col.setColumnAnchor(getInquiryUrl(element, col.getPropertyName())); } return col; }
From source file:org.ajax4jsf.builder.config.BuilderConfig.java
/** * Check all components for existing and default properties. * //from w w w . j a v a 2 s . co m * @param classpath - * classpath to find user components, renderers, tags * @throws ConfigurationException */ public void checkComponentProperties() throws ParsingException { // ClassLoader loader = getProject().createClassLoader(classpath); // if(null == loader) { // loader = this.getClass().getClassLoader(); // } // setLoader(loader); for (ListenerBean listener : getListeners()) { try { Class<?> listenerClass = Class.forName(listener.getComponentclass(), false, getLoader()); for (ComponentBean bean : getComponents()) { if (bean.getSuperclass() != null) { Class<?> componentSClass = Class.forName(bean.getSuperclass(), false, getLoader()); if (listenerClass.isAssignableFrom(componentSClass)) { PropertyBean listenerProperty = bean.getProperty(listener.getName()); if (null == listenerProperty) { listenerProperty = new PropertyBean(); listenerProperty.setName(listener.getName()); bean.addProperty(listenerProperty); listenerProperty.setClassname("javax.el.MethodExpression"); } Map<String, PropertyDescriptor> map = getPropertyDescriptors(componentSClass); PropertyDescriptor propertyDescriptor = map.get(listener.getName()); if (propertyDescriptor != null) { String componentPropertyName = propertyDescriptor.getPropertyType().getName(); if (!componentPropertyName.equals(listenerProperty.getClassname())) { _log.error(String.format("Overriding property type %s with %s for %s.%s", listenerProperty.getClassname(), componentPropertyName, bean.getClassname(), listener.getName())); } listenerProperty.setClassname(componentPropertyName); } // TODO - check existing property for compability with this listener. listenerProperty.setEl(true); listenerProperty.setElonly(true); listenerProperty.setAttachedstate(true); listenerProperty.setMethodargs(listener.getEventclass()); listener.addSuitableComponent(bean); } } } } catch (ClassNotFoundException e) { throw new BuildException(e); } listener.checkProperties(); } for (Iterator iter = this.getComponents().iterator(); iter.hasNext();) { ComponentBaseBean component = (ComponentBaseBean) iter.next(); component.checkProperties(); } for (Iterator iter = this.getValidators().iterator(); iter.hasNext();) { ComponentBaseBean component = (ComponentBaseBean) iter.next(); component.checkProperties(); } for (Iterator iter = this.getConverters().iterator(); iter.hasNext();) { ComponentBaseBean component = (ComponentBaseBean) iter.next(); component.checkProperties(); } }
From source file:com.springframework.beans.CachedIntrospectionResults.java
/** * Create a new CachedIntrospectionResults instance for the given class. * @param beanClass the bean class to analyze * @throws BeansException in case of introspection failure *//* w w w .j a v a 2s .c o m*/ private CachedIntrospectionResults(Class<?> beanClass) throws BeansException { try { if (logger.isTraceEnabled()) { logger.trace("Getting BeanInfo for class [" + beanClass.getName() + "]"); } BeanInfo beanInfo = null; for (BeanInfoFactory beanInfoFactory : beanInfoFactories) { beanInfo = beanInfoFactory.getBeanInfo(beanClass); if (beanInfo != null) { break; } } if (beanInfo == null) { // If none of the factories supported the class, fall back to the default beanInfo = (shouldIntrospectorIgnoreBeaninfoClasses ? Introspector.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO) : Introspector.getBeanInfo(beanClass)); } this.beanInfo = beanInfo; if (logger.isTraceEnabled()) { logger.trace("Caching PropertyDescriptors for class [" + beanClass.getName() + "]"); } this.propertyDescriptorCache = new LinkedHashMap<String, PropertyDescriptor>(); // This call is slow so we do it once. PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors(); for (PropertyDescriptor pd : pds) { if (Class.class.equals(beanClass) && ("classLoader".equals(pd.getName()) || "protectionDomain".equals(pd.getName()))) { // Ignore Class.getClassLoader() and getProtectionDomain() methods - nobody needs to bind to those continue; } if (logger.isTraceEnabled()) { logger.trace("Found bean property '" + pd.getName() + "'" + (pd.getPropertyType() != null ? " of type [" + pd.getPropertyType().getName() + "]" : "") + (pd.getPropertyEditorClass() != null ? "; editor [" + pd.getPropertyEditorClass().getName() + "]" : "")); } pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd); this.propertyDescriptorCache.put(pd.getName(), pd); } this.typeDescriptorCache = new ConcurrentReferenceHashMap<PropertyDescriptor, TypeDescriptor>(); } catch (IntrospectionException ex) { throw new FatalBeanException("Failed to obtain BeanInfo for class [" + beanClass.getName() + "]", ex); } finally { } }
From source file:org.kuali.kfs.sec.businessobject.lookup.AccessSecurityBalanceLookupableHelperServiceImpl.java
/** * @param element/* w ww.ja va 2 s . c o m*/ * @param attributeName * @return Column */ protected Column setupResultsColumn(BusinessObject element, String attributeName, BusinessObjectRestrictions businessObjectRestrictions) { Column col = new Column(); col.setPropertyName(attributeName); String columnTitle = getDataDictionaryService().getAttributeLabel(getBusinessObjectClass(), attributeName); if (StringUtils.isBlank(columnTitle)) { columnTitle = getDataDictionaryService().getCollectionLabel(getBusinessObjectClass(), attributeName); } col.setColumnTitle(columnTitle); col.setMaxLength(getDataDictionaryService().getAttributeMaxLength(getBusinessObjectClass(), attributeName)); Class formatterClass = getDataDictionaryService().getAttributeFormatter(getBusinessObjectClass(), attributeName); Formatter formatter = null; if (formatterClass != null) { try { formatter = (Formatter) formatterClass.newInstance(); col.setFormatter(formatter); } catch (InstantiationException e) { throw new RuntimeException( "Unable to get new instance of formatter class: " + formatterClass.getName()); } catch (IllegalAccessException e) { throw new RuntimeException( "Unable to get new instance of formatter class: " + formatterClass.getName()); } } // pick off result column from result list, do formatting String propValue = KFSConstants.EMPTY_STRING; Object prop = ObjectUtils.getPropertyValue(element, attributeName); // set comparator and formatter based on property type Class propClass = null; try { PropertyDescriptor propDescriptor = PropertyUtils.getPropertyDescriptor(element, col.getPropertyName()); if (propDescriptor != null) { propClass = propDescriptor.getPropertyType(); } } catch (Exception e) { throw new RuntimeException("Cannot access PropertyType for property " + "'" + col.getPropertyName() + "' " + " on an instance of '" + element.getClass().getName() + "'.", e); } // formatters if (prop != null) { // for Booleans, always use BooleanFormatter if (prop instanceof Boolean) { formatter = new BooleanFormatter(); } if (formatter != null) { propValue = (String) formatter.format(prop); } else { propValue = prop.toString(); } } // comparator col.setComparator(CellComparatorHelper.getAppropriateComparatorForPropertyClass(propClass)); col.setValueComparator(CellComparatorHelper.getAppropriateValueComparatorForPropertyClass(propClass)); propValue = maskValueIfNecessary(element.getClass(), col.getPropertyName(), propValue, businessObjectRestrictions); col.setPropertyValue(propValue); if (StringUtils.isNotBlank(propValue)) { col.setColumnAnchor(getInquiryUrl(element, col.getPropertyName())); } return col; }
From source file:ca.sqlpower.matchmaker.MatchMakerTestCase.java
/** * Returns a new value that is not equal to oldVal. The returned object * will always be a NEW instance compatible with oldVal. This differs from * {@link #modifyObject(MatchMakerObject, PropertyDescriptor, Object)} in that * this does not take mutability into account. * // w w w. ja v a 2 s . com * @param mmo The object to which the property belongs. You might need this * if you have a special case for certain types of objects. * @param property The property that should be modified. It belongs to mmo. * @param oldVal The existing value of the property. */ private Object getNewDifferentValue(MatchMakerObject mmo, PropertyDescriptor property, Object oldVal) throws IOException { Object newVal; // don't init here so compiler can warn if the // following code doesn't always give it a value if (property.getPropertyType() == Integer.TYPE || property.getPropertyType() == Integer.class) { if (oldVal == null) newVal = new Integer(0); else { newVal = ((Integer) oldVal) + 1; } } else if (property.getPropertyType() == Short.TYPE || property.getPropertyType() == Short.class) { if (oldVal == null) newVal = new Short("0"); else { Integer temp = (Short) oldVal + 1; newVal = Short.valueOf(temp.toString()); } } else if (property.getPropertyType() == String.class) { // make sure it's unique newVal = "new " + oldVal; } else if (property.getPropertyType() == Boolean.class || property.getPropertyType() == Boolean.TYPE) { if (oldVal == null) { newVal = new Boolean(false); } else { newVal = new Boolean(!((Boolean) oldVal).booleanValue()); } } else if (property.getPropertyType() == Long.class) { if (oldVal == null) { newVal = new Long(0L); } else { newVal = new Long(((Long) oldVal).longValue() + 1L); } } else if (property.getPropertyType() == BigDecimal.class) { if (oldVal == null) { newVal = new BigDecimal(0); } else { newVal = new BigDecimal(((BigDecimal) oldVal).longValue() + 1L); } } else if (property.getPropertyType() == MungeSettings.class) { newVal = new MungeSettings(); Integer processCount = ((MatchMakerSettings) newVal).getProcessCount(); if (processCount == null) { processCount = new Integer(0); } else { processCount = new Integer(processCount + 1); } ((MatchMakerSettings) newVal).setProcessCount(processCount); } else if (property.getPropertyType() == MergeSettings.class) { newVal = new MergeSettings(); Integer processCount = ((MatchMakerSettings) newVal).getProcessCount(); if (processCount == null) { processCount = new Integer(0); } else { processCount = new Integer(processCount + 1); } ((MatchMakerSettings) newVal).setProcessCount(processCount); } else if (property.getPropertyType() == SQLTable.class) { newVal = new SQLTable(); } else if (property.getPropertyType() == ViewSpec.class) { newVal = new ViewSpec("*", "test_table", "true"); } else if (property.getPropertyType() == File.class) { newVal = File.createTempFile("mmTest", ".tmp"); ((File) newVal).deleteOnExit(); } else if (property.getPropertyType() == PlFolder.class) { newVal = new PlFolder(); } else if (property.getPropertyType() == ProjectMode.class) { if (oldVal == ProjectMode.BUILD_XREF) { newVal = ProjectMode.FIND_DUPES; } else { newVal = ProjectMode.BUILD_XREF; } } else if (property.getPropertyType() == MergeActionType.class) { if (oldVal == MergeActionType.AUGMENT) { newVal = MergeActionType.SUM; } else { newVal = MergeActionType.AUGMENT; } } else if (property.getPropertyType() == MatchMakerTranslateGroup.class) { newVal = new MatchMakerTranslateGroup(); } else if (property.getPropertyType() == MatchMakerObject.class) { newVal = new TestingAbstractMatchMakerObject(); } else if (property.getPropertyType() == SQLColumn.class) { newVal = new SQLColumn(); } else if (property.getPropertyType() == Date.class) { newVal = new Date(); } else if (property.getPropertyType() == List.class) { newVal = new ArrayList(); } else if (property.getPropertyType() == Project.class) { newVal = new Project(); ((Project) newVal).setName("Fake_Project_" + System.currentTimeMillis()); } else if (property.getPropertyType() == SQLIndex.class) { return new SQLIndex("new index", false, "", "HASHED", ""); } else if (property.getPropertyType() == Color.class) { if (oldVal == null) { newVal = new Color(0xFAC157); } else { Color oldColor = (Color) oldVal; newVal = new Color((oldColor.getRGB() + 0xF00) % 0x1000000); } } else if (property.getPropertyType() == ChildMergeActionType.class) { if (oldVal != null && oldVal.equals(ChildMergeActionType.DELETE_ALL_DUP_CHILD)) { newVal = ChildMergeActionType.UPDATE_DELETE_ON_CONFLICT; } else { newVal = ChildMergeActionType.DELETE_ALL_DUP_CHILD; } } else if (property.getPropertyType() == MungeResultStep.class || property.getPropertyType() == DeDupeResultStep.class) { newVal = new DeDupeResultStep(); } else if (property.getPropertyType() == TableMergeRules.class) { if (oldVal == null) { newVal = mmo; } else { newVal = null; } } else if (property.getPropertyType() == PoolFilterSetting.class) { if (oldVal != PoolFilterSetting.EVERYTHING) { newVal = PoolFilterSetting.EVERYTHING; } else { newVal = PoolFilterSetting.INVALID_ONLY; } } else if (property.getPropertyType() == AutoValidateSetting.class) { if (oldVal != AutoValidateSetting.NOTHING) { newVal = AutoValidateSetting.NOTHING; } else { newVal = AutoValidateSetting.SERP_CORRECTABLE; } } else if (property.getPropertyType() == Point.class) { if (oldVal == null) { newVal = new Point(0, 0); } else { newVal = new Point(((Point) oldVal).x + 1, ((Point) oldVal).y + 1); } } else { throw new RuntimeException("This test case lacks a value for " + property.getName() + " (type " + property.getPropertyType().getName() + ") from " + mmo.getClass()); } if (newVal instanceof MatchMakerObject) { ((MatchMakerObject) newVal).setSession(session); } return newVal; }