当前位置: 首页>>代码示例>>Java>>正文


Java PropertyUtilsBean类代码示例

本文整理汇总了Java中org.apache.commons.beanutils.PropertyUtilsBean的典型用法代码示例。如果您正苦于以下问题:Java PropertyUtilsBean类的具体用法?Java PropertyUtilsBean怎么用?Java PropertyUtilsBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PropertyUtilsBean类属于org.apache.commons.beanutils包,在下文中一共展示了PropertyUtilsBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: artistToDto

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
private ArtistDto artistToDto(Artist artist) {
    ArtistDto artistDto = new ArtistDto();
    PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
    try {
        propertyUtilsBean.copyProperties(artistDto, artist);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        throw new RuntimeException("Can not create artist Data Transfer Object", e);
    }

    String slug = slugService.getSlugForArtist(artist);
    artistDto.setSlug(slug);

    if (artist.getBeginDate() != null) {
        artistDto.setBeginDateDay(artist.getBeginDate().toDate());
    }

    if (artist.getEndDate() != null) {
        artistDto.setEndDateDay(artist.getEndDate().toDate());
    }

    return artistDto;
}
 
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:23,代码来源:ArtistService.java

示例2: dtoToArtist

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
private Artist dtoToArtist(ArtistDto artistDto) {
    Artist artist = new Artist();
    PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
    try {
        propertyUtilsBean.copyProperties(artist, artistDto);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        throw new RuntimeException("Can not create Artist from Data Transfer Object", e);
    }

    if (artistDto.getAlbums() != null) {
        List<Album.ShortInfo> albums = artistDto.getAlbums().stream()
                .map(this::albumDtoToShortInfo)
                .collect(Collectors.toList());
        artist.setAlbums(albums);
    }

    if (artistDto.getBeginDateDay() != null) {
        artist.setBeginDate(new ODate(artistDto.getBeginDateDay()));
    }

    if (artistDto.getEndDateDay() != null) {
        artist.setEndDate(new ODate(artistDto.getEndDateDay()));
    }

    return artist;
}
 
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:27,代码来源:ArtistService.java

示例3: albumToDto

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
private AlbumDto albumToDto(Album album) {

        AlbumDto albumDto = new AlbumDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(albumDto, album);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create album Data Transfer Object", e);
        }

        String slug = slugService.getSlugForAlbum(album);
        albumDto.setSlug(slug);

        if (album.getArtists() != null && !album.getArtists().isEmpty()) {

            List<ArtistDto> artistDtoList = album.getArtists().stream()
                    .map(this::artistShortInfoToDto)
                    .collect(toList());

            albumDto.setArtistList(artistDtoList);
        }

        return albumDto;
    }
 
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:25,代码来源:RecommendationService.java

示例4: afterPropertiesSet

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    beanContext = new BackendBeanContext(beanFactory);
    BeanContextBean.getInstance().setBeanContext(beanContext);
    VenusBeanUtilsBean.setInstance(new BackendBeanUtilsBean(new ConvertUtilsBean(), new PropertyUtilsBean(), beanContext));
    AthenaExtensionResolver.getInstance().resolver();
    CodeMapScanner.getCodeMap();

    List<ServiceConfig> serviceConfigList = new ArrayList<ServiceConfig>();
    Map<String, InterceptorMapping> interceptors = new HashMap<String, InterceptorMapping>();
    Map<String, InterceptorStackConfig> interceptorStacks = new HashMap<String, InterceptorStackConfig>();
    loadVenusService(serviceConfigList, interceptors, interceptorStacks);
    loadMonitorService(interceptors, interceptorStacks);
    loadRegistryService(interceptors, interceptorStacks);
    initMonitor(serviceConfigList, interceptors, interceptorStacks);
}
 
开发者ID:blusechen,项目名称:venus,代码行数:17,代码来源:XmlFileServiceManager.java

示例5: listPermittedTransitions

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
/**
 * JAVADOC Method Level Comments
 *
 * @param workflowDefinitionId JAVADOC.
 * @param placeId JAVADOC.
 * @param entity JAVADOC.
 *
 * @return JAVADOC.
 */
@Override
public Collection<String> listPermittedTransitions(String workflowDefinitionId, String placeId,
    PersistableEntity entity) {
    Assert.notNull(entity);

    Map<String, Object> map;

    try {
        map = new PropertyUtilsBean().describe(entity);
    } catch (Exception e) {
        throw new RuntimeException("Failure to convert object to map", e);
    }

    return listPermittedTransitions(workflowDefinitionId, placeId, entity.getApplicationType(),
        map);
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:26,代码来源:TransitionsAccessorImpl.java

示例6: getPropertyType

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
protected Type getPropertyType(Object instance, String propertyName) {
	try {
		if (instance != null) {
			Field field = instance.getClass().getField(propertyName);
			return field.getGenericType();
		} else {
			// instance is null for anonymous class, use default type
		}
	} catch (NoSuchFieldException e1) {
		try {
			BeanUtilsBean beanUtilsBean = BeanUtilsBean.getInstance();
			PropertyUtilsBean propertyUtils = beanUtilsBean.getPropertyUtils();
			PropertyDescriptor propertyDescriptor = propertyUtils.getPropertyDescriptor(instance, propertyName);
			return propertyDescriptor.getReadMethod().getGenericReturnType();
		} catch (Exception e2) {
			// nothing
		}
	} catch (Exception e) {
		// ignore other exceptions
	}
	// return Object class type by default
	return Object.class;
}
 
开发者ID:Kyunghwa-Yoo,项目名称:StitchRTSP,代码行数:24,代码来源:Input.java

示例7: handleRequestInternal

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
                                                                                                      throws Exception {
    long clusterId = 0;
    try {
        clusterId = Long.parseLong(request.getParameter("clusterId").trim());
    } catch (Exception e) {
        throw new IllegalArgumentException("parameter 'clusterId' is invalid:" + request.getParameter("clusterId"));
    }
    ClusterDO cluster = xmlAccesser.getClusterDAO().getClusterById(clusterId);
    Map<String, Object> clusterMap = new PropertyUtilsBean().describe(cluster);
    clusterMap.remove("class");
    clusterMap.remove("name");
    clusterMap.remove("deployDesc");

    clusterMap.put("name", CobarStringUtil.htmlEscapedString(cluster.getName()));
    clusterMap.put("deployDesc", CobarStringUtil.htmlEscapedString(cluster.getDeployDesc()));
    return new ModelAndView("m_editCluster",
        new FluenceHashMap<String, Object>().putKeyValue("cluster", clusterMap));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:22,代码来源:EditClusterPage.java

示例8: fillBeanDefaults

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
/**
     * Fills the bean with the default values, by calling all the getters and setting the returned value.
     * @param bean
     * @return
     * @throws IllegalAccessException
     * @throws NoSuchMethodException
     * @throws InvocationTargetException
     */
    public static DiffableBean fillBeanDefaults(DiffableBean bean) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        BeanMap map = new BeanMap(bean);
        PropertyUtilsBean propUtils = new PropertyUtilsBean();

        for (Object propNameObject : map.keySet()) {
            String propertyName = (String) propNameObject;
            Object property1 = propUtils.getProperty(bean, propertyName);
            if(property1 == null || !DiffableBean.class.isAssignableFrom(property1.getClass())) {
                if(property1 != null) {
//					System.out.println(propertyName + ": " + property1.toString());
                    org.apache.commons.beanutils.BeanUtils.setProperty(bean, propertyName, property1);
                }
            } else {
//				System.out.println("RECURSIVE: " + propertyName);
                property1 = fillBeanDefaults((DiffableBean) property1);
                org.apache.commons.beanutils.BeanUtils.setProperty(bean, propertyName, property1);
            }
        }
        return bean;
    }
 
开发者ID:miguel-porto,项目名称:flora-on-server,代码行数:29,代码来源:BeanUtils.java

示例9: updateBean

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
/**
 * Updates a oldBean with all non-null values in the newBean.
 * @param cls
 * @param ignoreProperties
 * @param oldBean
 * @param newBean
 * @param <T>
 * @return
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 * @throws FloraOnException
 * @throws InstantiationException
 */
public static <T extends DiffableBean> T updateBean(Class<T> cls, Collection<String> ignoreProperties, T oldBean, T newBean) throws IllegalAccessException
        , InvocationTargetException, NoSuchMethodException, FloraOnException, InstantiationException {
    BeanMap propertyMap = new BeanMap(oldBean);    // we assume beans are the same class! so we take the first as a model
    PropertyUtilsBean propUtils = new PropertyUtilsBean();
    BeanUtilsBean bub = createBeanUtilsNull();

    T out = cls.newInstance();

    for (Object propNameObject : propertyMap.keySet()) {
        String propertyName = (String) propNameObject;
        if(ignoreProperties != null && ignoreProperties.contains(propertyName)) continue;
        System.out.println("PROP: " + propertyName);
        Object newProperty;

        newProperty = propUtils.getProperty(newBean, propertyName);

        if(newProperty == null)
            bub.setProperty(out, propertyName, propUtils.getProperty(oldBean, propertyName));
        else
            bub.setProperty(out, propertyName, newProperty);
        // TODO: nested beans
    }
    return out;
}
 
开发者ID:miguel-porto,项目名称:flora-on-server,代码行数:39,代码来源:BeanUtils.java

示例10: handleRequestInternal

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    long clusterId = 0;
    try {
        clusterId = Long.parseLong(request.getParameter("clusterId").trim());
    } catch (Exception e) {
        throw new IllegalArgumentException("parameter 'clusterId' is invalid:" + request.getParameter("clusterId"));
    }
    ClusterDO cluster = xmlAccesser.getClusterDAO().getClusterById(clusterId);
    Map<String, Object> clusterMap = new PropertyUtilsBean().describe(cluster);
    clusterMap.remove("class");
    clusterMap.remove("name");
    clusterMap.remove("deployDesc");

    clusterMap.put("name", CobarStringUtil.htmlEscapedString(cluster.getName()));
    clusterMap.put("deployDesc", CobarStringUtil.htmlEscapedString(cluster.getDeployDesc()));
    return new ModelAndView(
            "m_editCluster",
            new FluenceHashMap<String, Object>().putKeyValue("cluster", clusterMap));
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:23,代码来源:EditClusterPage.java

示例11: addNonDefaultAttribute

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
public void addNonDefaultAttribute(XmlBuilder senderXml, ISender sender, String attribute) {
	try {
		PropertyUtilsBean pub = new PropertyUtilsBean();

		if (pub.isReadable(sender,attribute) && pub.isWriteable(sender,attribute)) {
			String value = BeanUtils.getProperty(sender,attribute);

			Object defaultSender;
			Class[] classParm = null;
			Object[] objectParm = null;

			Class cl = sender.getClass();
			java.lang.reflect.Constructor co = cl.getConstructor(classParm);
			defaultSender = co.newInstance(objectParm);

			String defaultValue = BeanUtils.getProperty(defaultSender,attribute);				
			if (value!=null && !value.equals(defaultValue)) {
				senderXml.addAttribute(attribute,value);
			}
		}
	} catch (Exception e) {
		log.error("cannot retrieve attribute ["+attribute+"] from sender ["+ClassUtils.nameOf(sender)+"]");
	}
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:25,代码来源:SenderMonitorAdapter.java

示例12: getPropertyType

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
protected Type getPropertyType(Object instance, String propertyName) {
    try {
        if (instance != null) {
            Field field = instance.getClass().getField(propertyName);
            return field.getGenericType();
        } else {
            // instance is null for anonymous class, use default type
        }
    } catch (NoSuchFieldException e1) {
        try {
            BeanUtilsBean beanUtilsBean = BeanUtilsBean.getInstance();
            PropertyUtilsBean propertyUtils = beanUtilsBean.getPropertyUtils();
            PropertyDescriptor propertyDescriptor = propertyUtils.getPropertyDescriptor(instance, propertyName);
            return propertyDescriptor.getReadMethod().getGenericReturnType();
        } catch (Exception e2) {
            // nothing
        }
    } catch (Exception e) {
        // ignore other exceptions
    }
    // return Object class type by default
    return Object.class;
}
 
开发者ID:Red5,项目名称:red5-io,代码行数:24,代码来源:Input.java

示例13: lookup

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
@Override
public String lookup(String key) {
    if (this.map == null) {
        return null;
    } else {
        int dotIndex = key.indexOf(".");
        Object obj = this.map.get(key.substring(0,
                                                dotIndex < 0 ? key.length() : dotIndex));
        if (obj instanceof Map) {
            return new MapOfMapStrLookup(((Map) obj)).lookup(key.substring(key.indexOf(".") + 1));
        } else if (obj != null && !(obj instanceof String) && key.contains(".")) {
            final String subkey = key.substring(key.indexOf(".") + 1);
            for (PropertyDescriptor descriptor : new PropertyUtilsBean().getPropertyDescriptors(obj)) {
                if (descriptor.getName().equals(subkey)) {
                    try {
                        return descriptor.getReadMethod().invoke(obj).toString();
                    } catch (Exception ex) {
                        continue;
                    }
                }
            }
        }

        return obj == null ? "" : obj.toString();
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:27,代码来源:VariableInterpolation.java

示例14: albumToDto

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
private AlbumDto albumToDto(Album album) {

        AlbumDto albumDto = new AlbumDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(albumDto, album);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create album Data Transfer Object", e);
        }

        String slug = slugService.getSlugForAlbum(album);
        albumDto.setSlug(slug);

        if (album.getTrackList() != null && !album.getTrackList().isEmpty()) {

            List<TrackDto> trackDtoList = album.getTrackList().stream()
                    .map(this::trackToDto)
                    .collect(toList());

            albumDto.setTrackList(trackDtoList);
        }

        if (album.getArtists() != null && !album.getArtists().isEmpty()) {

            List<ArtistDto> artistDtoList = album.getArtists().stream()
                    .map(this::artistShortInfoToDto)
                    .collect(toList());

            albumDto.setArtistList(artistDtoList);
        }

        if (album.getReleasedDate() != null) {
            albumDto.setReleasedDateDay(album.getReleasedDate().toDate());
        }

        return albumDto;
    }
 
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:38,代码来源:AlbumService.java

示例15: trackToDto

import org.apache.commons.beanutils.PropertyUtilsBean; //导入依赖的package包/类
private TrackDto trackToDto(Track track) {

        TrackDto trackDto = new TrackDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(trackDto, track);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create track Data Transfer Object", e);
        }

        return trackDto;
    }
 
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:13,代码来源:AlbumService.java


注:本文中的org.apache.commons.beanutils.PropertyUtilsBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。