private TypePrinter<GraphQLEnumType> enumPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } printComments(out, type, ""); out.format("enum %s%s {\n", type.getName(), directivesString(type.getDirectives())); List<GraphQLEnumValueDefinition> values = type.getValues() .stream() .sorted(Comparator.comparing(GraphQLEnumValueDefinition::getName)) .collect(toList()); for (GraphQLEnumValueDefinition enumValueDefinition : values) { printComments(out, enumValueDefinition, " "); out.format(" %s%s\n", enumValueDefinition.getName(), directivesString(enumValueDefinition.getDirectives())); } out.format("}\n\n"); }; }
public Builder(GraphQLEnumType existing) { this.name = existing.getName(); this.description = existing.getDescription(); this.definition = existing.getDefinition(); this.values.putAll(getByName(existing.getValues(), GraphQLEnumValueDefinition::getName)); this.directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
public Builder(GraphQLEnumType existing) { this.name = existing.getName(); this.description = existing.getDescription(); this.definition = existing.getDefinition(); this.values.putAll(getByName(existing.getValues(), GraphQLEnumValueDefinition::getName)); this.directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
@Test public void enumeration() { ProcessingElementsContainer container = testedProcessingElementsContainer(); GraphQLType enumeration = container.getDefaultTypeFunction().buildType(A.class, null,container); assertTrue(enumeration instanceof GraphQLEnumType); List<GraphQLEnumValueDefinition> values = ((GraphQLEnumType) enumeration).getValues(); assertEquals(values.stream(). map(GraphQLEnumValueDefinition::getName).collect(Collectors.toList()), Arrays.asList("someA", "B")); assertEquals(values.stream(). map(GraphQLEnumValueDefinition::getDescription).collect(Collectors.toList()), Arrays.asList("a", "B")); }
private TypePrinter<GraphQLEnumType> enumPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } SchemaPrinterComparatorEnvironment environment = SchemaPrinterComparatorEnvironment.newEnvironment() .parentType(GraphQLEnumType.class) .elementType(GraphQLEnumValueDefinition.class) .build(); Comparator<? super GraphQLType> comparator = options.comparatorRegistry.getComparator(environment); printComments(out, type, ""); out.format("enum %s%s {\n", type.getName(), directivesString(GraphQLEnumType.class, type.getDirectives())); List<GraphQLEnumValueDefinition> values = type.getValues() .stream() .sorted(comparator) .collect(toList()); for (GraphQLEnumValueDefinition enumValueDefinition : values) { printComments(out, enumValueDefinition, " "); out.format(" %s%s\n", enumValueDefinition.getName(), directivesString(GraphQLEnumValueDefinition.class, enumValueDefinition.getDirectives())); } out.format("}\n\n"); }; }