GraphQL Java注释 - 嵌套类上的@GraphQLField

时间:2017-10-11 21:13:18

标签: graphql graphql-java

我有一个类,我想用它作为我的GraphQL架构的查询。我正在使用GraphQL Annotations java库构建GraphQL架构。

#include <cstdint>
#include <cstring>
#include <cmath>

int __float_as_int (float a)
{
    int r;
    memcpy (&r, &a, sizeof(r));
    return r;
}

float __int_as_float (int a)
{
    float r;
    memcpy (&r, &a, sizeof(r));
    return r;
}

/* branch free implementation of ((cond) ? a : b). cond must be in {0,1} */
int32_t mux (int cond, int32_t a, int32_t b)
{
    int32_t mask = cond * 0xffffffff;
    return (mask & a) | (~mask & b);
}

/* portable implementation of leading zero count with invariant runtime */
int clz (uint32_t x)
{
    int n = 32;
    uint32_t y;

    y = x >> 16; n = mux (!!y, n - 16, n); x = mux (!!y, y, x);
    y = x >>  8; n = mux (!!y, n -  8, n); x = mux (!!y, y, x);
    y = x >>  4; n = mux (!!y, n -  4, n); x = mux (!!y, y, x);
    y = x >>  2; n = mux (!!y, n -  2, n); x = mux (!!y, y, x);
    y = x >>  1; n = mux (!!y, n -  2, n - x);
    return n;
}

/* maximum error 0.85417 ulp */
float my_logf (float a)
{
    float m, r, s, t, i, f;
    int32_t e, ia, ii, ir, it, iu, shift;
    const int32_t abs_mask = 0x7fffffff;
    const int32_t qnan_bit = 0x00400000;
    const int32_t pos_inf = 0x7f800000;
    const int32_t neg_inf = 0xff800000;
    const int32_t indefinite = 0xffc00000;
    const int32_t tiny_float = 0x00800000; // 1.17549435e-38f
    const int32_t huge_float = 0x7f7fffff; // 3.40282347e+38f 

    ia = __float_as_int (a);

    /* result for exceptional cases */
    iu = mux (ia < 0, indefinite, ia); // return QNaN INDEFINITE
    iu = mux ((ia & abs_mask) == 0, neg_inf, iu); // return -Inf
    iu = mux ((ia & abs_mask) > pos_inf, ia | qnan_bit, iu); // convert to QNaN

    /* result for non-exceptional cases */
    shift = clz (ia) - 8;
    it = (ia << shift) + ((23 - shift) << 23);
    ii = mux (ia < tiny_float, -23, 0);
    it = mux (ia < tiny_float, it, ia);

    /* split argument into exponent and mantissa parts */
    e = (it - 0x3f2aaaab) & 0xff800000;
    m = __int_as_float (it - e);
    i = fmaf ((float)e, 1.19209290e-7f, (float)ii);

    /* m in [2/3, 4/3] */
    f = m - 1.0f;
    s = f * f;
    /* Compute log1p(f) for f in [-1/3, 1/3] */
    r =             -0.130310059f; 
    t =              0.140869141f; 
    r = fmaf (r, s, -0.121489234f);
    t = fmaf (t, s,  0.139809728f);
    r = fmaf (r, s, -0.166844666f);
    t = fmaf (t, s,  0.200121239f);
    r = fmaf (r, s, -0.249996305f);
    r = fmaf (t, f, r);
    r = fmaf (r, f,  0.333331943f);
    r = fmaf (r, f, -0.500000000f);
    r = fmaf (r, s, f);
    r = fmaf (i, 0.693147182f, r); // log(2) 

    /* late selection between exceptional and non-exceptional result */
    ir = __float_as_int (r);
    ir = mux ((ia > 0) && (ia <= huge_float), ir, iu);
    r = __int_as_float (ir);

    return r;
}

C是来自另一个java库的类。

@GraphQL
class A {
  @GraphQLField
  String a;
  @GraphQLField
  String b;
  @GraphQLField
  C c; 
}

有没有办法使用public class C { String value; } 构建架构,而无需在class A的字段@GraphQLField上添加value注释?

0 个答案:

没有答案