/** * <p>Convert the value to an object of the specified class (if * possible).</p> * * @param value Value to be converted (may be null) * @param type Class of the value to be converted to * @return The converted value */ @Override protected Object convert(final Object value, final Class<?> type) { return getConvertUtils().convert(value, type); } }
@Override protected ConvertUtilsBean initialValue() { ConvertUtilsBean ret = BeanUtilsBean2.getInstance().getConvertUtils(); ret.deregister(); ret.register(false, true, 1); return ret; } };
public void update ( final Map<String, String> parameters ) throws Exception { new BeanUtilsBean2 ().populate ( this.targetBean, parameters ); } }
public Dictionary<String, ?> getProperties () { try { final Dictionary<String, Object> result = new Hashtable<String, Object> (); final Map<?, ?> properties = new BeanUtilsBean2 ().describe ( this.targetBean ); for ( final Map.Entry<?, ?> entry : properties.entrySet () ) { if ( entry.getValue () != null ) { result.put ( entry.getKey ().toString (), entry.getValue () ); } } return result; } catch ( final Exception e ) { logger.warn ( "Failed to get dictionary", e ); return new Hashtable<String, Object> ( 1 ); } }
/** * 拷贝属性 * * @param sources 源 * @param targetClass 目标 class * @param <T> 目标类型 * @return 目标集合 */ public static < T > List< T > copyPropertiesToList ( List< ? > sources , Class<T> targetClass) { AssertUtils.isTrue( CollectionUtils.isEmpty( sources ), "sources is null" ); AssertUtils.isTrue( targetClass == null, "targetClass is null" ); List< T > targets = new ArrayList<>( sources.size() ); for ( Object source : sources ) { T target; try { target = targetClass.newInstance(); BeanUtilsBean2.getInstance().copyProperties( target , source ); } catch ( InstantiationException | IllegalAccessException | InvocationTargetException e ) { throw new RuntimeException( e.getMessage() , e ); } targets.add( target ); } return targets; }
public void update ( final Map<String, String> parameters ) throws Exception { new BeanUtilsBean2 ().populate ( this.targetBean, parameters ); } }
public Dictionary<String, ?> getProperties () { try { final Dictionary<String, Object> result = new Hashtable<String, Object> (); final Map<?, ?> properties = new BeanUtilsBean2 ().describe ( this.targetBean ); for ( final Map.Entry<?, ?> entry : properties.entrySet () ) { if ( entry.getValue () != null ) { result.put ( entry.getKey ().toString (), entry.getValue () ); } } return result; } catch ( final Exception e ) { logger.warn ( "Failed to get dictionary", e ); return new Hashtable<String, Object> ( 1 ); } }
/** * <p>Convert the value to an object of the specified class (if * possible).</p> * * @param value Value to be converted (may be null) * @param type Class of the value to be converted to * @return The converted value */ @Override protected Object convert(final Object value, final Class<?> type) { return getConvertUtils().convert(value, type); } }
try { @SuppressWarnings("unchecked") Map<String, Object> description = BeanUtilsBean2.getInstance().describe(container); for (String o : description.keySet()) { Object object = description.get(o);
/** * <p>Convert the value to an object of the specified class (if * possible).</p> * * @param value Value to be converted (may be null) * @param type Class of the value to be converted to * @return The converted value */ protected Object convert(Object value, Class type) { return getConvertUtils().convert(value, type); } }
/** * 生成Token * @param username 用户账号 * @param password 密码 * @return 加密串 */ public String jwtToken(String username, String password) { Authority authority = this.jwtiFace.getAuthority(username, password); Preconditions.checkArgument(null != authority, "用户名或密码错误"); try { Map<String, String> beanMap = BeanUtilsBean2.getInstance().describe(authority); String token = JWTUtils.jwtToken(ImmutableMap.copyOf(beanMap), jjwtConfigure.getPrivateKey(), jjwtConfigure.getExpire()); log.info("username:{}, token:{}", username, token); //WebUtils.setCookie(WebUtils.getHttpServletResponse(), jjwtConfigure.getDomain(), jjwtConfigure.getCookieName(), token, jjwtConfigure.getCookieMaxAge()); return token; } catch (Exception e) { throw new RuntimeException("生成签名失败"); } }
/** * <p>Convert the value to an object of the specified class (if * possible).</p> * * @param value Value to be converted (may be null) * @param type Class of the value to be converted to * @return The converted value */ protected Object convert(Object value, Class type) { return getConvertUtils().convert(value, type); } }
try { @SuppressWarnings("unchecked") Map<String, Object> description = BeanUtilsBean2.getInstance().describe(container); for (String o : description.keySet()) { Object object = description.get(o);
/** * <p>Convert the value to an object of the specified class (if * possible).</p> * * @param value Value to be converted (may be null) * @param type Class of the value to be converted to * @return The converted value */ protected Object convert(Object value, Class type) { return getConvertUtils().convert(value, type); } }
/** * <p>Convert the value to an object of the specified class (if * possible).</p> * * @param value Value to be converted (may be null) * @param type Class of the value to be converted to * @return The converted value */ @Override protected Object convert(final Object value, final Class<?> type) { return getConvertUtils().convert(value, type); } }