Package com.badlogic.gdx.utils.reflect

Examples of com.badlogic.gdx.utils.reflect.Field


    Class type = object.getClass();
    ObjectMap<String, FieldMetadata> fields = typeToFields.get(type);
    if (fields == null) fields = cacheFields(type);
    FieldMetadata metadata = fields.get(fieldName);
    if (metadata == null) throw new SerializationException("Field not found: " + fieldName + " (" + type.getName() + ")");
    Field field = metadata.field;
    JsonValue jsonValue = jsonMap.get(jsonName);
    if (jsonValue == null) return;
    if (elementType == null) elementType = metadata.elementType;
    try {
      field.set(object, readValue(field.getType(), elementType, jsonValue));
    } catch (ReflectionException ex) {
      throw new SerializationException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex);
    } catch (SerializationException ex) {
      ex.addTrace(field.getName() + " (" + type.getName() + ")");
      throw ex;
    } catch (RuntimeException runtimeEx) {
      SerializationException ex = new SerializationException(runtimeEx);
      ex.addTrace(field.getName() + " (" + type.getName() + ")");
      throw ex;
    }
  }
View Full Code Here


          if (debug) System.out.println("Ignoring unknown field: " + child.name() + " (" + type.getName() + ")");
          continue;
        } else
          throw new SerializationException("Field not found: " + child.name() + " (" + type.getName() + ")");
      }
      Field field = metadata.field;
      // if (entry.value == null) continue; // I don't remember what this did. :(
      try {
        field.set(object, readValue(field.getType(), metadata.elementType, child));
      } catch (ReflectionException ex) {
        throw new SerializationException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex);
      } catch (SerializationException ex) {
        ex.addTrace(field.getName() + " (" + type.getName() + ")");
        throw ex;
      } catch (RuntimeException runtimeEx) {
        SerializationException ex = new SerializationException(runtimeEx);
        ex.addTrace(field.getName() + " (" + type.getName() + ")");
        throw ex;
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.utils.reflect.Field

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.