本文整理汇总了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;
}
示例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));
}
示例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();
}
示例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("");
}
示例6: getEnumValues
import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
protected List<GraphQLEnumValueDefinition> getEnumValues(Object object) {
return getStrategies().getEnumValuesStrategy().getEnumValueDefinitions(object);
}
示例7: GraphQLEnumTypeExt
import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
public GraphQLEnumTypeExt(String name, String description, List<GraphQLEnumValueDefinition> values) {
super(name, description, values);
}
示例8: value
import graphql.schema.GraphQLEnumValueDefinition; //导入依赖的package包/类
public Builder value(String name) {
values.add(new GraphQLEnumValueDefinition(name, null, name));
return this;
}
示例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);