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


Java GraphQLEnumType.Builder方法代码示例

本文整理汇总了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());
	}
}
 
开发者ID:deptofdefense,项目名称:anet,代码行数:18,代码来源:AnetResourceDataFetcher.java

示例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;
}
 
开发者ID:yahoo,项目名称:elide,代码行数:25,代码来源:GraphQLConversionUtils.java

示例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();
}
 
开发者ID:google,项目名称:rejoiner,代码行数:8,代码来源:ProtoToGql.java

示例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();
}
 
开发者ID:deptofdefense,项目名称:anet,代码行数:9,代码来源:GraphQLUtils.java

示例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());

}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:14,代码来源:EnumSetMapper.java

示例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());
}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:13,代码来源:EnumSetMapper.java

示例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();
}
 
开发者ID:graphql-java,项目名称:graphql-java-type-generator,代码行数:16,代码来源:FullTypeGenerator.java

示例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();
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:9,代码来源:EnumMapper.java

示例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();
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:9,代码来源:EnumMapper.java

示例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();
}
 
开发者ID:nfl,项目名称:glitr,代码行数:18,代码来源:GraphQLEnumTypeFactory.java

示例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();
}
 
开发者ID:nfl,项目名称:gold,代码行数:6,代码来源:EnumType.java

示例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;
}
 
开发者ID:bpatters,项目名称:schemagen-graphql,代码行数:47,代码来源:GraphQLObjectMapper.java

示例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));
}
 
开发者ID:leangen,项目名称:graphql-spqr,代码行数:5,代码来源:EnumMapper.java


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