@Test public void getAttributeValueByDefaultTest() { UseEntity entity = new UseEntity(); assertEquals("1234567890", entity.attributeValue("id", "1234567890")); }
@SuppressWarnings("unchecked") public <T> T attributeValue(final String fieldName) { if (StringUtils.isEmpty(fieldName)) { throw new IllegalArgumentException("属性名不能为空"); } try { if (fields.containsKey(fieldName)) { final Field field = fields.get(fieldName); final String fieldGetName = parGetName(field.getName()); if (hasMethodName(fieldGetName)) { return (T) methods.get(fieldGetName).invoke(this); } } else { throw new NoSuchFieldException("无效的属性名称: " + fieldName); } } catch (final Throwable e) { throw new EntityException(e.getMessage(), e); } return null; }
BaseEntity implements Cloneable, Serializable { @SuppressWarnings("unchecked") public <T> T attributeValue(final String fieldName) { if (StringUtils.isEmpty(fieldName)) { throw new IllegalArgumentException("属性名不能为空"); } try { if (fields.containsKey(fieldName)) { final Field field = fields.get(fieldName); final String fieldGetName = parGetName(field.getName()); if (hasMethodName(fieldGetName)) { return (T) methods.get(fieldGetName).invoke(this); } } else { throw new NoSuchFieldException("无效的属性名称: " + fieldName); } } catch (final Throwable e) { throw new EntityException(e.getMessage(), e); } return null; } }
BaseEntity implements Cloneable, Serializable { @SuppressWarnings("unchecked") public <T> T attributeValue(final String fieldName) { if (StringUtils.isEmpty(fieldName)) { throw new IllegalArgumentException("属性名不能为空"); } try { if (fields.containsKey(fieldName)) { final Field field = fields.get(fieldName); final String fieldGetName = parGetName(field.getName()); if (hasMethodName(fieldGetName)) { return (T) methods.get(fieldGetName).invoke(this); } } else { throw new NoSuchFieldException("无效的属性名称: " + fieldName); } } catch (final Throwable e) { throw new EntityException(e.getMessage(), e); } return null; }  }
BaseEntity implements Cloneable, Serializable { @SuppressWarnings("unchecked") public <T> T attributeValue(final String fieldName) { if (StringUtils.isEmpty(fieldName)) { throw new IllegalArgumentException("属性名不能为空"); } try { if (fields.containsKey(fieldName)) { final Field field = fields.get(fieldName); final String fieldGetName = parGetName(field.getName()); if (hasMethodName(fieldGetName)) { return (T) methods.get(fieldGetName).invoke(this); } } else { throw new NoSuchFieldException("无效的属性名称: " + fieldName); } } catch (final Throwable e) { throw new EntityException(e.getMessage(), e); } return null; }  String[] attributeNames(); @SuppressWarnings("unchecked") T attributeValue(final String fieldName); T attributeValue(final String fieldName, final T defaultValue); void setAttributeValue(final String fieldName, final Object value); void setAttributeValue(final String fieldName, final Object value, final boolean isCase); Map<String, Object> beanToMap(); static T mapToBean(Map<String, Object> beanMap, Class<T> beanType); static List<T> mapToBeans(final List<Map<String, Object>> beanMaps, final Class<T> beanType); static Map<String, Method> paramMethods(Class<?> cls); static Map<String, Field> paramFields(Class<?> cls); Collection<Method> methods(); Collection<Field> fields(); @Override BaseEntity clone(); @Override String toString(); }
BaseEntity implements Cloneable, Serializable { @SuppressWarnings("unchecked") public <T> T attributeValue(final String fieldName) { if (StringUtils.isEmpty(fieldName)) { throw new IllegalArgumentException("属性名不能为空"); } try { if (fields.containsKey(fieldName)) { final Field field = fields.get(fieldName); final String fieldGetName = parGetName(field.getName()); if (hasMethodName(fieldGetName)) { return (T) methods.get(fieldGetName).invoke(this); } } else { throw new NoSuchFieldException("无效的属性名称: " + fieldName); } } catch (final Throwable e) { throw new EntityException(e.getMessage(), e); } return null; }  String[] attributeNames(); @SuppressWarnings("unchecked") T attributeValue(final String fieldName); T attributeValue(final String fieldName, final T defaultValue); void setAttributeValue(final String fieldName, final Object value); void setAttributeValue(final String fieldName, final Object value, final boolean isCase); Map<String, Object> beanToMap(); static T mapToBean(Map<String, Object> beanMap, Class<T> beanType); static List<T> mapToBeans(final List<Map<String, Object>> beanMaps, final Class<T> beanType); static Map<String, Method> paramMethods(Class<?> cls); static Map<String, Field> paramFields(Class<?> cls); Collection<Method> methods(); Collection<Field> fields(); @Override BaseEntity clone(); @Override String toString();  }