graphql.language.ListType Java Examples
The following examples show how to use
graphql.language.ListType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: STModel.java From graphql-apigen with Apache License 2.0 | 6 votes |
private void addImports(Collection<String> imports, Type type) { if ( type instanceof ListType ) { imports.add("java.util.List"); addImports(imports, ((ListType)type).getType()); } else if ( type instanceof NonNullType ) { addImports(imports, ((NonNullType)type).getType()); } else if ( type instanceof TypeName ) { String name = ((TypeName)type).getName(); if ( BUILTINS.containsKey(name) ) { String importName = BUILTINS.get(name); if ( null == importName ) return; imports.add(importName); } else { TypeEntry refEntry = referenceTypes.get(name); // TODO: scalar name may be different... should read annotations for scalars. if ( null == refEntry ) { throw new RuntimeException("Unknown type '"+name+"' was not defined in the schema"); } else { imports.add(refEntry.getPackageName() + "." + name); } } } else { throw new RuntimeException("Unknown Type="+type.getClass().getName()); } }
Example #2
Source File: GraphQLIntrospectionResultToSchema.java From js-graphql-intellij-plugin with MIT License | 6 votes |
@SuppressWarnings("unchecked") private Type createTypeIndirection(Map<String, Object> type) { String kind = (String) type.get("kind"); switch (kind) { case "INTERFACE": case "OBJECT": case "UNION": case "ENUM": case "INPUT_OBJECT": case "SCALAR": return TypeName.newTypeName().name((String) type.get("name")).build(); case "NON_NULL": return NonNullType.newNonNullType().type(createTypeIndirection((Map<String, Object>) type.get("ofType"))).build(); case "LIST": return ListType.newListType().type(createTypeIndirection((Map<String, Object>) type.get("ofType"))).build(); default: return assertShouldNeverHappen("Unknown kind %s", kind); } }
Example #3
Source File: Generator.java From smallrye-graphql with Apache License 2.0 | 5 votes |
@Override public String toString() { if (type instanceof ListType) return toListJava((ListType) type); if (type instanceof NonNullType) return toNonNullJava((NonNullType) type); if (type instanceof TypeName) return toJava((TypeName) type); throw new UnsupportedOperationException("unexpected type of type"); // unreachable }
Example #4
Source File: GqlParentType.java From manifold with Apache License 2.0 | 5 votes |
private ListType getListType( Type type ) { if( type instanceof ListType ) { return (ListType)type; } if( type instanceof TypeName ) { return null; } return getListType( ((NonNullType)type).getType() ); }
Example #5
Source File: GqlParentType.java From manifold with Apache License 2.0 | 5 votes |
private Type getComponentType( Type type ) { if( type instanceof ListType ) { return getComponentType( ((ListType)type).getType() ); } if( type instanceof NonNullType ) { return getComponentType( ((NonNullType)type).getType() ); } return type; }
Example #6
Source File: GqlParentType.java From manifold with Apache License 2.0 | 5 votes |
private String convertType( SrcLinkedClass owner, Type type, String component ) { ListType listType = getListType( type ); if( listType != null ) { return List.class.getSimpleName() + '<' + convertType( owner, listType.getType(), component ) + '>'; } return owner.getDisambiguatedNameInNest( component ); }
Example #7
Source File: GqlParentType.java From manifold with Apache License 2.0 | 5 votes |
private SrcType makeSrcType( SrcLinkedClass owner, Type type, boolean typeParam ) { SrcType srcType; if( type instanceof ListType ) { srcType = new SrcType( "List" ); srcType.addTypeParam( makeSrcType( owner, ((ListType)type).getType(), true ) ); } else if( type instanceof TypeName ) { String typeName = getJavaClassName( owner, (TypeName)type, typeParam ); srcType = new SrcType( typeName ); if( !typeParam ) { Class<?> javaClass = getJavaClass( (TypeName)type, false ); srcType.setPrimitive( javaClass != null && javaClass.isPrimitive() ); } } else if( type instanceof NonNullType ) { Type theType = ((NonNullType)type).getType(); srcType = makeSrcType( owner, theType, typeParam ); if( !typeParam && !srcType.isPrimitive() ) { srcType.addAnnotation( new SrcAnnotationExpression( NotNull.class.getSimpleName() ) ); } } else { throw new IllegalStateException( "Unhandled type: " + type.getClass().getTypeName() ); } return srcType; }
Example #8
Source File: STModel.java From graphql-apigen with Apache License 2.0 | 5 votes |
private String toGraphQLType(Type type) { if ( type instanceof ListType ) { return "new GraphQLList(" + toGraphQLType(((ListType)type).getType()) + ")"; } else if ( type instanceof NonNullType ) { return toGraphQLType(((NonNullType)type).getType()); } else if ( type instanceof TypeName ) { String name = ((TypeName)type).getName(); if ( BUILTINS.containsKey(name) ) { return "Scalars.GraphQL" + name; } return "new GraphQLTypeReference(\""+name+"\")"; } else { throw new UnsupportedOperationException("Unknown Type="+type.getClass().getName()); } }
Example #9
Source File: STModel.java From graphql-apigen with Apache License 2.0 | 5 votes |
private String toJavaTypeName(Type type) { if ( type instanceof ListType ) { return "List<" + toJavaTypeName(((ListType)type).getType()) + ">"; } else if ( type instanceof NonNullType ) { return toJavaTypeName(((NonNullType)type).getType()); } else if ( type instanceof TypeName ) { String name = ((TypeName)type).getName(); String rename = RENAME.get(name); // TODO: scalar type directive to get implementation class... if ( null != rename ) return rename; return name; } else { throw new UnsupportedOperationException("Unknown Type="+type.getClass().getName()); } }
Example #10
Source File: Generator.java From smallrye-graphql with Apache License 2.0 | 4 votes |
private String toListJava(ListType type) { imports.add("java.util.List"); return "List<" + new JavaType(type.getType(), fieldNames) + ">"; }