예제 #1
0
  private void tstFields() {
    ReflectField surname = _iClass.getDeclaredField("surname");
    ReflectField birthdate = _iClass.getDeclaredField("birthdate");
    ReflectField[] fields = _iClass.getDeclaredFields();
    _assert(fields.length == 3);
    _assert(fields[0] == surname);
    _assert(fields[1] == birthdate);

    Object person = _iClass.newInstance();
    _assert(birthdate.get(person) == null);
    surname.set(person, "Cleese");
    _assert(surname.get(person).equals("Cleese"));
  }
예제 #2
0
 private Object initGenericObjects() {
   GenericClass personClass = initGenericClass();
   ReflectField surname = personClass.getDeclaredField("surname");
   ReflectField birthdate = personClass.getDeclaredField("birthdate");
   // ReflectField nArray = personClass.getDeclaredField("nArray");
   Object person = personClass.newInstance();
   surname.set(person, "John");
   //		/int[][] arrayData = new int[2][2];
   // todo: FIXME: nArray doesn't work
   // nArray.set(person, arrayData);
   birthdate.set(person, new Date());
   fixture().db().store(person);
   fixture().db().commit();
   return person;
 }
예제 #3
0
 protected void assertNullItem(Object obj) throws Exception {
   ReflectClass claxx = reflector().forObject(obj);
   ReflectField[] fields = claxx.getDeclaredFields();
   for (int i = 0; i < fields.length; ++i) {
     ReflectField field = fields[i];
     if (field.isStatic() || field.isTransient()) {
       continue;
     }
     ReflectClass type = field.getFieldType();
     if (container().classMetadataForReflectClass(type).isValueType()) {
       continue;
     }
     Object value = field.get(obj);
     Assert.isNull(value);
   }
 }
예제 #4
0
 private void initialize() {
   this.valueField = reflectClass.getField(VALUE_FIELD_NAME);
   this.hasValueField = null != valueField;
   this.valueType = hasValueField ? valueField.getType() : null;
 }
예제 #5
0
 public Object getValue(Object enumConstant) {
   return null != valueField ? valueField.getValue(enumConstant) : enumConstant.toString();
 }