本文整理汇总了Java中graphql.schema.GraphQLEnumType.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java GraphQLEnumType.Builder方法的具体用法?Java GraphQLEnumType.Builder怎么用?Java GraphQLEnumType.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphql.schema.GraphQLEnumType
的用法示例。
在下文中一共展示了GraphQLEnumType.Builder方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildValidArgs
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
private void buildValidArgs(boolean isListFetcher) {
validArgs = new LinkedList<GraphQLArgument>();
validArgs.addAll(arguments.values());
//Only accept the f argument if we can actually do anything with it.
if (fetchers.size() > 0) {
String enumName = resource.getBeanClass().getSimpleName() + (isListFetcher ? "s" : "") + "_functions";
GraphQLEnumType.Builder functionNamesEnum = GraphQLEnumType.newEnum()
.name(enumName);
for (String functionName : fetchers.keySet()) {
functionNamesEnum.value(functionName);
}
validArgs.add(GraphQLArgument.newArgument()
.name("f")
.type(functionNamesEnum.build())
.build());
}
}
示例2: classToEnumType
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
/**
* Converts an enum to a GraphQLEnumType.
* @param enumClazz the Enum to convert
* @return A GraphQLEnum type for class.
*/
public GraphQLEnumType classToEnumType(Class<?> enumClazz) {
if (enumConversions.containsKey(enumClazz)) {
return enumConversions.get(enumClazz);
}
Enum [] values = (Enum []) enumClazz.getEnumConstants();
GraphQLEnumType.Builder builder = newEnum().name(toValidNameName(enumClazz.getName()));
for (Enum value : values) {
builder.value(toValidNameName(value.name()), value);
}
GraphQLEnumType enumResult = builder.build();
enumConversions.put(enumClazz, enumResult);
return enumResult;
}
示例3: convert
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
static GraphQLEnumType convert(EnumDescriptor descriptor) {
GraphQLEnumType.Builder builder = GraphQLEnumType.newEnum().name(getReferenceName(descriptor));
for (EnumValueDescriptor value : descriptor.getValues()) {
builder.value(value.getName());
}
return builder.build();
}
示例4: gqlEnumBuilder
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
public static GraphQLEnumType gqlEnumBuilder(Class<? extends Enum<?>> enumClazz) {
Enum<?>[] constants = enumClazz.getEnumConstants();
GraphQLEnumType.Builder builder = GraphQLEnumType.newEnum().name(enumClazz.getSimpleName());
for (Enum<?> s : constants) {
builder.value(s.name(), s);
}
return builder.build();
}
示例5: getOutputType
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
@Override
public GraphQLOutputType getOutputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) {
Class<?> classType = (Class<?>) type;
Class<?> enumClassType = classType.getComponentType();
GraphQLEnumType.Builder enumType = GraphQLEnumType.newEnum()
.name(graphQLObjectMapper.getTypeNamingStrategy().getTypeName(graphQLObjectMapper, enumClassType));
for (Object value : enumClassType.getEnumConstants()) {
enumType.value(value.toString(), value);
}
return new GraphQLList(enumType.build());
}
示例6: getInputType
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
@Override
public GraphQLInputType getInputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) {
Class<?> classType = (Class<?>) type;
Class<?> enumClassType = classType.getComponentType();
GraphQLEnumType.Builder enumType = GraphQLEnumType.newEnum()
.name(graphQLObjectMapper.getTypeNamingStrategy().getTypeName(graphQLObjectMapper, enumClassType));
for (Object value : enumClassType.getEnumConstants()) {
enumType.value(value.toString(), value);
}
return new GraphQLList(enumType.build());
}
示例7: generateEnumType
import graphql.schema.GraphQLEnumType; //导入方法依赖的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();
}
示例8: toGraphQLType
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
@Override
public GraphQLEnumType toGraphQLType(String typeName, AnnotatedType javaType, Set<Type> abstractTypes, OperationMapper operationMapper, BuildContext buildContext) {
GraphQLEnumType.Builder enumBuilder = newEnum()
.name(typeName)
.description(buildContext.typeInfoGenerator.generateTypeDescription(javaType));
addOptions(enumBuilder, ClassUtils.getRawType(javaType.getType()));
return enumBuilder.build();
}
示例9: toGraphQLInputType
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
@Override
public GraphQLEnumType toGraphQLInputType(String typeName, AnnotatedType javaType, Set<Type> abstractTypes, OperationMapper operationMapper, BuildContext buildContext) {
GraphQLEnumType.Builder enumBuilder = newEnum()
.name(typeName)
.description(buildContext.typeInfoGenerator.generateInputTypeDescription(javaType));
addOptions(enumBuilder, ClassUtils.getRawType(javaType.getType()));
return enumBuilder.build();
}
示例10: createEnumType
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
/**
* Creates the {@link GraphQLEnumType} dynamically for the given enum
*
* @param clazz enum class to be introspected
* @return {@link GraphQLEnumType} object exposed via graphQL
*/
public static GraphQLEnumType createEnumType(Class clazz) {
GraphQLEnumType.Builder builder = newEnum()
.name(clazz.getSimpleName())
.description(ReflectionUtil.getDescriptionFromAnnotatedElement(clazz));
for (Object constant : clazz.getEnumConstants()) {
builder.value(constant.toString(), constant);
}
return builder.build();
}
示例11: buildEnumType
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
private GraphQLEnumType buildEnumType(String postFix) {
GraphQLEnumType.Builder builder = newEnum().name(getMemberFieldName() + postFix);
getEnumValues().forEach(entry -> builder.value(entry.getName(), entry.getValue()));
return builder.build();
}
示例12: getOutputType
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
@Override
public GraphQLOutputType getOutputType(Type type) {
GraphQLOutputType rv;
Class<?> classType;
String typeName = this.getTypeNamingStrategy().getTypeName(this, type);
if (getOutputTypeCache().containsKey(typeName)) {
return getOutputTypeCache().get(typeName);
}
Optional<IGraphQLTypeMapper> typeMapper = getCustomTypeMapper(type);
if (typeMapper.isPresent()) {
rv = getOutputTypeCache().put(typeName, typeMapper.get().getOutputType(this, type));
} else if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
Type rawType = parameterizedType.getRawType();
Class<?> rawClass = (Class<?>) rawType;
typeMapper = getCustomTypeMapper(rawClass);
if (typeMapper.isPresent()) {
rv = getOutputTypeCache().put(typeName, typeMapper.get().getOutputType(this, type));
} else {
return buildObject(type, rawClass);
}
} else if (type instanceof TypeVariable) {
TypeVariable<?> vType = (TypeVariable<?>) type;
return getOutputType(typeArguments.peek().get(vType.getName()));
} else {
classType = getClassFromType(type);
Optional<GraphQLScalarType> graphQLType = getIfPrimitiveType(classType);
if (graphQLType.isPresent()) {
rv = getOutputTypeCache().put(typeName, graphQLType.get());
} else if (classType.isEnum()) {
GraphQLEnumType.Builder enumType = GraphQLEnumType.newEnum().name(typeNamingStrategy.getTypeName(this, type));
for (Object value : classType.getEnumConstants()) {
enumType.value(value.toString(), value);
}
rv = getOutputTypeCache().put(typeName, enumType.build());
} else {
rv = buildObject(type, classType);
}
}
return rv;
}
示例13: addOptions
import graphql.schema.GraphQLEnumType; //导入方法依赖的package包/类
private void addOptions(GraphQLEnumType.Builder enumBuilder, Class<?> enumClass) {
Arrays.stream(enumClass.getEnumConstants()).forEach(
enumConst -> enumBuilder.value(((Enum) enumConst).name(), enumConst));
}