Gets the JsonObject representation of the given field object.
@param field represents a template field
@return the json object
489856
private static JsonObject getFieldJsonObject(Field field) {
        JsonObject fieldObj = new JsonObject();
        fieldObj.add("type", field.getType());
        fieldObj.add("key", field.getKey());
        fieldObj.add("displayName", field.getDisplayName());

        String fieldDesc = field.getDescription();
        if (fieldDesc != null) {
            fieldObj.add("description", field.getDescription());
        }

        Boolean fieldIsHidden = field.getIsHidden();
        if (fieldIsHidden != null) {
            fieldObj.add("hidden", field.getIsHidden());
        }

        JsonArray array = new JsonArray();
        List<String> options = field.getOptions();
        if (options != null && !options.isEmpty()) {
            for (String option : options) {
                JsonObject optionObj = new JsonObject();
                optionObj.add("key", option);

                array.add(optionObj);
            }
            fieldObj.add("options", array);
        }

        return fieldObj;
    }
1337669
public static JsonArray getArray(JsonObject object, String field, JsonArray defaultValue) {
        final JsonValue value = object.get(field);
        if (value == null || value.isNull()) {
            return defaultValue;
        } else {
            return value.asArray();
        }
    }
834268
public static JsonNode getFieldValue(JsonNode doc, String field) {
        StringTokenizer tkz = new StringTokenizer(field, ". ");
        JsonNode trc = doc;
        while (tkz.hasMoreTokens() && trc != null) {
            String tok = tkz.nextToken();
            trc = trc.get(tok);
        }
        return trc;
    }
130039
public JsonObject getJsonObject() {

        JsonObject obj = new JsonObject();
        obj.add("field", this.field);

        obj.add("value", this.value);

        return obj;
    }
698919
public JSONObject toJSON() {
        JSONObject ret = new JSONObject();
        ret.put("url", url);
        if (env != null) {
            ret.put("env", env);
        }
        return ret;
    }
155836
static Object getObjectFromJson(JsonObject jsonObj, Class clazz, Set<Attribute> columns)
    {
        Object obj = KunderaCoreUtils.createNewInstance(clazz);
        for (Attribute column : columns)
        {
            JsonElement value = jsonObj.get(((AbstractAttribute) column).getJPAColumnName());
            setFieldValue(obj, column, value);
        }
        return obj;
    }
1097029
public ByteBuffer getValue(String field) throws IOException {
        int hash = Arrays.hashCode(field.getBytes());
        return getValue(structure.valueHash2Index.get(hash));
    }
26190
public JSONObject toJSON() {
        JSONObject ret = new JSONObject();
        ret.put("type",type.getName());

        if (targetConfig != null) {
            ret.put("target", targetConfig.toJSON());
        }
        if (pathParts != null) {
            try {
                ret.put("path",getPath());
            } catch (UnsupportedOperationException exp) {
                // Happens when request doesnt support paths
            }
        }
        return ret;
    }
70325
public static String getMapFieldKeyType(Field field) {
        FieldType type = field.getType();
        if (!(type instanceof Message)) {
            throw new IllegalArgumentException(field.toString());
        }
        Message entryType = (Message) type;
        ScalarFieldType keyType = (ScalarFieldType) entryType.getField(MAP_ENTRY_KEY).getType();
        return ScalarFieldTypeUtil.getWrapperType(keyType);
    }
1263726
public static final String getter(Field field, String fieldName)
    {
        Class<?> type = field.getType();
        if (type.isPrimitive() && "boolean".equals(type.getName()))
        {
            return isser(fieldName);
        }
        else
        {
            return getter(fieldName);
        }
    }
452733
public static Object getObject(Object from, Field field)
    {
        if (!field.isAccessible())
        {
            field.setAccessible(true);
        }
        try
        {
            return field.get(from);
        }
        catch (IllegalArgumentException iarg)
        {
            throw new PropertyAccessException(iarg);
        }
        catch (IllegalAccessException iacc)
        {
            throw new PropertyAccessException(iacc);
        }
    }
717149
public static String getString(Object from, Field field)
    {
        PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field);
        Object object = getObject(from, field);
        return object != null ? accessor.toString(object) : null;
    }
465500
public static long getLong(JsonObject object, String field) {
        final JsonValue value = object.get(field);
        throwExceptionIfNull(value, field);
        return value.asLong();
    }
1164898
@SuppressWarnings("unchecked")
    public static <T extends Object> T getFieldValue(Object obj, Field field) {
        Assert.notNull(obj, "obj不能为空");
        Assert.notNull(field, "field不能为空");

        try {
            return (T) field.get(obj);
        } catch (IllegalArgumentException e) {
            throw new ReflectException(e);
        } catch (IllegalAccessException e) {
            String msg = StringUtils.format("类型[{0}]的字段[{1}]不允许访问", obj.getClass(),
                field.getName());
            log.error(msg);
            throw new ReflectException(msg, e);
        }
    }
721175
@Override
  public JsonElement serialize(CMAField field, Type type, JsonSerializationContext context) {
    JsonObject json = new JsonObject();

    add(json, ATTR_ID, field.getId());
    add(json, ATTR_NAME, field.getName());
    add(json, ATTR_TYPE, field.getType());
    add(json, ATTR_LINK_TYPE, field.getLinkType());
    add(json, ATTR_REQUIRED, field.isRequired());
    add(json, ATTR_DISABLED, field.isDisabled());
    add(json, ATTR_OMITTED, field.isOmitted());
    add(json, ATTR_LOCALIZED, field.isLocalized());

    List<Map<String, Object>> validations = field.getValidations();
    if (validations != null) {
      json.add(ATTR_VALIDATIONS, context.serialize(validations,
          new TypeToken<List<Map<String, Object>>>() {
          }
          .getType()));
    }

    Map<String, Object> arrayItems = field.getArrayItems();
    if (arrayItems != null) {
      json.add(ATTR_ARRAY_ITEMS, context.serialize(arrayItems, Map.class));
    }

    return json;
  }
408520
public Object get(String field) {
        if (target == null) {
            return null;
        }

        return get(field, field, target);
    }
1205567
public static String getFieldType(Field field) {
        FieldType type = field.getType();
        if (type instanceof ScalarFieldType) {
            ScalarFieldType scalarFieldType = (ScalarFieldType) type;
            return ScalarFieldTypeUtil.getPrimitiveType(scalarFieldType);
        }
        if (type instanceof UserType) {
            UserType userType = (UserType) type;
            return UserTypeUtil.getCanonicalName(userType);
        }
        throw new IllegalArgumentException(field.toString());
    }