当前位置: 首页>>代码示例>>Java>>正文


Java GraphQLEnumValueDefinition类代码示例

本文整理汇总了Java中graphql.schema.GraphQLEnumValueDefinition的典型用法代码示例。如果您正苦于以下问题:Java GraphQLEnumValueDefinition类的具体用法?Java GraphQLEnumValueDefinition怎么用?Java GraphQLEnumValueDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GraphQLEnumValueDefinition类属于graphql.schema包,在下文中一共展示了GraphQLEnumValueDefinition类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEnumValueDefinitions

import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
@Override
public List<GraphQLEnumValueDefinition> getEnumValueDefinitions(Object object) {
    Class<?> clazz = ReflectionUtils.extractClassFromSupportedObject(object);
    if (clazz == null) return null;
    if (!clazz.isEnum()) {
        return null;
    }
    
    List<GraphQLEnumValueDefinition> valueObjects =
            new ArrayList<GraphQLEnumValueDefinition>();
    for (Object value : clazz.getEnumConstants()) {
        valueObjects.add(new GraphQLEnumValueDefinition(
                value.toString(), "Autogen " + value.toString(), value));
    }
    return valueObjects;
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:17,代码来源:EnumValues_Reflection.java

示例2: testEnum

import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
@Test
public void testEnum() {
    logger.debug("testEnum");
    Object enumObj = testContext.getOutputType(graphql.java.generator.Enum.class);
    Assert.assertThat(enumObj, instanceOf(GraphQLEnumType.class));
    Matcher<Iterable<GraphQLEnumValueDefinition>> hasItemsMatcher =
            hasItems(
                    hasProperty("name", is("A")),
                    hasProperty("name", is("B")),
                    hasProperty("name", is("C")));
    assertThat(((GraphQLEnumType)enumObj).getValues(), hasItemsMatcher);
    
    enumObj = testContext.getOutputType(graphql.java.generator.EmptyEnum.class);
    Assert.assertThat(enumObj, instanceOf(GraphQLEnumType.class));
    assertThat(((GraphQLEnumType)enumObj).getValues(),
            instanceOf(List.class));
    assertThat(((GraphQLEnumType)enumObj).getValues().size(),
            is(0));
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:20,代码来源:TypeGeneratorWithFieldsGenIntegrationTest.java

示例3: toEnum

import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
private static String toEnum(GraphQLEnumType type) {
  ArrayList<String> values = new ArrayList<>();
  int i = 0;
  for (GraphQLEnumValueDefinition value : type.getValues()) {
    if (value.getName().equals("UNRECOGNIZED")) {
      continue;
    }
    values.add(String.format("%s = %d;", value.getName(), i));
    i++;
  }
  return String.format(
      "message %s {\n %s\n enum Enum {\n%s\n}\n}",
      type.getName(), getJspb(type), Joiner.on("\n").join(values));
}
 
开发者ID:google,项目名称:rejoiner,代码行数:15,代码来源:SchemaToProto.java

示例4: generateEnumType

import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
protected GraphQLEnumType generateEnumType(Object object) {
    String typeName = getGraphQLTypeNameOrIdentityCode(object);

    List<GraphQLEnumValueDefinition> enumValues = getEnumValues(object);
    if (enumValues == null) {
        return null;
    }
    GraphQLEnumType.Builder builder = newEnum();
    builder.name(typeName);
    builder.description(getTypeDescription(object));
    for (GraphQLEnumValueDefinition value : enumValues) {
        builder.value(value.getName(), value.getValue(), value.getDescription());
    }
    return builder.build();
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:16,代码来源:FullTypeGenerator.java

示例5: getNameByValue

import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
private Object getNameByValue(Object value) {
    Object normalizedValue = enumToStringIfAny(value);
    for (GraphQLEnumValueDefinition valueDefinition : getValues()) {
        if (normalizedValue.equals(valueDefinition.getValue())) return valueDefinition.getName();
    }
    throw new GraphQLException("");
}
 
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:8,代码来源:GraphQLEnumTypeExt.java

示例6: getEnumValues

import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
protected List<GraphQLEnumValueDefinition> getEnumValues(Object object) {
    return getStrategies().getEnumValuesStrategy().getEnumValueDefinitions(object);
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:4,代码来源:TypeGenerator.java

示例7: GraphQLEnumTypeExt

import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
public GraphQLEnumTypeExt(String name, String description, List<GraphQLEnumValueDefinition> values) {
    super(name, description, values);
}
 
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:4,代码来源:GraphQLEnumTypeExt.java

示例8: value

import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
public Builder value(String name) {
    values.add(new GraphQLEnumValueDefinition(name, null, name));
    return this;
}
 
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:5,代码来源:GraphQLEnumTypeExt.java

示例9: getEnumValueDefinitions

import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
/**
 * 
 * @param object A representative "type" object, the exact type of which is contextual
 * @return Must return null if not an enum.
 */
List<GraphQLEnumValueDefinition> getEnumValueDefinitions(Object object);
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:7,代码来源:EnumValuesStrategy.java


注:本文中的graphql.schema.GraphQLEnumValueDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。