idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
7,500
public boolean remove ( String path , String httpMethod ) { if ( StringUtils . isEmpty ( path ) ) { throw new IllegalArgumentException ( "path cannot be null or blank" ) ; } if ( StringUtils . isEmpty ( httpMethod ) ) { throw new IllegalArgumentException ( "httpMethod cannot be null or blank" ) ; } HttpMethod method = ...
Removes a particular route from the collection of those that have been previously routed . Search for a previously established routes using the given path and HTTP method removing any matches that are found .
7,501
public boolean remove ( String path ) { if ( StringUtils . isEmpty ( path ) ) { throw new IllegalArgumentException ( "path cannot be null or blank" ) ; } return removeRoute ( ( HttpMethod ) null , path ) ; }
Removes a particular route from the collection of those that have been previously routed . Search for a previously established routes using the given path and removes any matches that are found .
7,502
private Map < String , RouteEntry > getAcceptedMimeTypes ( List < RouteEntry > routes ) { Map < String , RouteEntry > acceptedTypes = new HashMap < > ( ) ; for ( RouteEntry routeEntry : routes ) { if ( ! acceptedTypes . containsKey ( routeEntry . acceptedType ) ) { acceptedTypes . put ( routeEntry . acceptedType , rout...
can be cached? I don t think so .
7,503
public void add ( String route , String acceptType , Object target ) { try { int singleQuoteIndex = route . indexOf ( SINGLE_QUOTE ) ; String httpMethod = route . substring ( 0 , singleQuoteIndex ) . trim ( ) . toLowerCase ( ) ; String url = route . substring ( singleQuoteIndex + 1 , route . length ( ) - 1 ) . trim ( )...
Parse and validates a route and adds it
7,504
public String queryParamOrDefault ( String queryParam , String defaultValue ) { String value = queryParams ( queryParam ) ; return value != null ? value : defaultValue ; }
Gets the query param or returns default value
7,505
@ SuppressWarnings ( "unchecked" ) public < T > T attribute ( String attribute ) { return ( T ) servletRequest . getAttribute ( attribute ) ; }
Gets the value of the provided attribute
7,506
public Session session ( ) { if ( session == null || ! validSession ) { validSession ( true ) ; session = new Session ( servletRequest . getSession ( ) , this ) ; } return session ; }
Returns the current session associated with this request or if the request does not have a session creates one .
7,507
public String cookie ( String name ) { Cookie [ ] cookies = servletRequest . getCookies ( ) ; if ( cookies != null ) { for ( Cookie cookie : cookies ) { if ( cookie . getName ( ) . equals ( name ) ) { return cookie . getValue ( ) ; } } } return null ; }
Gets cookie by name .
7,508
public static ServerConnector createSocketConnector ( Server server , String host , int port ) { Assert . notNull ( server , "'server' must not be null" ) ; Assert . notNull ( host , "'host' must not be null" ) ; HttpConnectionFactory httpConnectionFactory = createHttpConnectionFactory ( ) ; ServerConnector connector =...
Creates an ordinary non - secured Jetty server jetty .
7,509
public static ServerConnector createSecureSocketConnector ( Server server , String host , int port , SslStores sslStores ) { Assert . notNull ( server , "'server' must not be null" ) ; Assert . notNull ( host , "'host' must not be null" ) ; Assert . notNull ( sslStores , "'sslStores' must not be null" ) ; SslContextFac...
Creates a ssl jetty socket jetty . Keystore required truststore optional . If truststore not specified keystore will be reused .
7,510
public String stem ( String s ) { if ( stem ( s . toCharArray ( ) , s . length ( ) ) ) return toString ( ) ; else return s ; }
Stem a word provided as a String . Returns the result as a String .
7,511
public < T > T set ( Object jsonObject , Object newVal , Configuration configuration ) { notNull ( jsonObject , "json can not be null" ) ; notNull ( configuration , "configuration can not be null" ) ; EvaluationContext evaluationContext = path . evaluate ( jsonObject , jsonObject , configuration , true ) ; for ( PathRe...
Set the value this path points to in the provided jsonObject
7,512
public < T > T put ( Object jsonObject , String key , Object value , Configuration configuration ) { notNull ( jsonObject , "json can not be null" ) ; notEmpty ( key , "key can not be null or empty" ) ; notNull ( configuration , "configuration can not be null" ) ; EvaluationContext evaluationContext = path . evaluate (...
Adds or updates the Object this path points to in the provided jsonObject with a key with a value
7,513
@ SuppressWarnings ( { "unchecked" } ) public < T > T read ( URL jsonURL ) throws IOException { return read ( jsonURL , Configuration . defaultConfiguration ( ) ) ; }
Applies this JsonPath to the provided json URL
7,514
public static JsonPath compile ( String jsonPath , Predicate ... filters ) { notEmpty ( jsonPath , "json can not be null or empty" ) ; return new JsonPath ( jsonPath , filters ) ; }
Compiles a JsonPath
7,515
@ SuppressWarnings ( { "unchecked" } ) public static < T > T read ( String json , String jsonPath , Predicate ... filters ) { return new ParseContextImpl ( ) . parse ( json ) . read ( jsonPath , filters ) ; }
Creates a new JsonPath and applies it to the provided Json string
7,516
private RootPathToken invertScannerFunctionRelationship ( final RootPathToken path ) { if ( path . isFunctionPath ( ) && path . next ( ) instanceof ScanPathToken ) { PathToken token = path ; PathToken prior = null ; while ( null != ( token = token . next ( ) ) && ! ( token instanceof FunctionPathToken ) ) { prior = tok...
In the event the writer of the path referenced a function at the tail end of a scanner augment the query such that the root node is the function and the parameter to the function is the scanner . This way we maintain relative sanity in the path expression functions either evaluate scalar values or arrays they re not re...
7,517
protected boolean checkArrayModel ( String currentPath , Object model , EvaluationContextImpl ctx ) { if ( model == null ) { if ( ! isUpstreamDefinite ( ) ) { return false ; } else { throw new PathNotFoundException ( "The path " + currentPath + " is null" ) ; } } if ( ! ctx . jsonProvider ( ) . isArray ( model ) ) { if...
Check if model is non - null and array .
7,518
public static PathFunction newFunction ( String name ) throws InvalidPathException { Class functionClazz = FUNCTIONS . get ( name ) ; if ( functionClazz == null ) { throw new InvalidPathException ( "Function with name: " + name + " does not exist." ) ; } else { try { return ( PathFunction ) functionClazz . newInstance ...
Returns the function by name or throws InvalidPathException if function not found .
7,519
public Criteria and ( String key ) { checkComplete ( ) ; return new Criteria ( this . criteriaChain , ValueNode . toValueNode ( prefixPath ( key ) ) ) ; }
Static factory method to create a Criteria using the provided key
7,520
public Criteria is ( Object o ) { this . criteriaType = RelationalOperator . EQ ; this . right = ValueNode . toValueNode ( o ) ; return this ; }
Creates a criterion using equality
7,521
public Criteria regex ( Pattern pattern ) { notNull ( pattern , "pattern can not be null" ) ; this . criteriaType = RelationalOperator . REGEX ; this . right = ValueNode . toValueNode ( pattern ) ; return this ; }
Creates a criterion using a Regex
7,522
public static Criteria parse ( String criteria ) { if ( criteria == null ) { throw new InvalidPathException ( "Criteria can not be null" ) ; } String [ ] split = criteria . trim ( ) . split ( " " ) ; if ( split . length == 3 ) { return create ( split [ 0 ] , split [ 1 ] , split [ 2 ] ) ; } else if ( split . length == 1...
Parse the provided criteria
7,523
public static Criteria create ( String left , String operator , String right ) { Criteria criteria = new Criteria ( ValueNode . toValueNode ( left ) ) ; criteria . criteriaType = RelationalOperator . fromString ( operator ) ; criteria . right = ValueNode . toValueNode ( right ) ; return criteria ; }
Creates a new criteria
7,524
public Configuration addEvaluationListeners ( EvaluationListener ... evaluationListener ) { return Configuration . builder ( ) . jsonProvider ( jsonProvider ) . mappingProvider ( mappingProvider ) . options ( options ) . evaluationListener ( evaluationListener ) . build ( ) ; }
Creates a new Configuration by the provided evaluation listeners to the current listeners
7,525
public Configuration addOptions ( Option ... options ) { EnumSet < Option > opts = EnumSet . noneOf ( Option . class ) ; opts . addAll ( this . options ) ; opts . addAll ( asList ( options ) ) ; return Configuration . builder ( ) . jsonProvider ( jsonProvider ) . mappingProvider ( mappingProvider ) . options ( opts ) ....
Creates a new configuration by adding the new options to the options used in this configuration .
7,526
public Configuration setOptions ( Option ... options ) { return Configuration . builder ( ) . jsonProvider ( jsonProvider ) . mappingProvider ( mappingProvider ) . options ( options ) . evaluationListener ( evaluationListeners ) . build ( ) ; }
Creates a new configuration with the provided options . Options in this configuration are discarded .
7,527
public static Configuration defaultConfiguration ( ) { Defaults defaults = getEffectiveDefaults ( ) ; return Configuration . builder ( ) . jsonProvider ( defaults . jsonProvider ( ) ) . options ( defaults . options ( ) ) . build ( ) ; }
Creates a new configuration based on default values
7,528
public Object getMapValue ( Object obj , String key ) { Map m = ( Map ) obj ; if ( ! m . containsKey ( key ) ) { return JsonProvider . UNDEFINED ; } else { return m . get ( key ) ; } }
Extracts a value from an map
7,529
@ SuppressWarnings ( "unchecked" ) public void setProperty ( Object obj , Object key , Object value ) { if ( isMap ( obj ) ) ( ( Map ) obj ) . put ( key . toString ( ) , value ) ; else { throw new JsonPathException ( "setProperty operation cannot be used with " + obj != null ? obj . getClass ( ) . getName ( ) : "null" ...
Sets a value in an object
7,530
@ SuppressWarnings ( "unchecked" ) public void removeProperty ( Object obj , Object key ) { if ( isMap ( obj ) ) ( ( Map ) obj ) . remove ( key . toString ( ) ) ; else { List list = ( List ) obj ; int index = key instanceof Integer ? ( Integer ) key : Integer . parseInt ( key . toString ( ) ) ; list . remove ( index ) ...
Removes a value in an object or array
7,531
@ SuppressWarnings ( "unchecked" ) public Collection < String > getPropertyKeys ( Object obj ) { if ( isArray ( obj ) ) { throw new UnsupportedOperationException ( ) ; } else { return ( ( Map ) obj ) . keySet ( ) ; } }
Returns the keys from the given object
7,532
public int length ( Object obj ) { if ( isArray ( obj ) ) { return ( ( List ) obj ) . size ( ) ; } else if ( isMap ( obj ) ) { return getPropertyKeys ( obj ) . size ( ) ; } else if ( obj instanceof String ) { return ( ( String ) obj ) . length ( ) ; } throw new JsonPathException ( "length operation cannot be applied to...
Get the length of an array or object
7,533
public static < T > List < T > toList ( final Class < T > type , final EvaluationContext ctx , final List < Parameter > parameters ) { List < T > values = new ArrayList ( ) ; if ( null != parameters ) { for ( Parameter param : parameters ) { consume ( type , ctx , values , param . getValue ( ) ) ; } } return values ; }
Translate the collection of parameters into a collection of values of type T .
7,534
public static void consume ( Class expectedType , EvaluationContext ctx , Collection collection , Object value ) { if ( ctx . configuration ( ) . jsonProvider ( ) . isArray ( value ) ) { for ( Object o : ctx . configuration ( ) . jsonProvider ( ) . toIterable ( value ) ) { if ( o != null && expectedType . isAssignableF...
Either consume the object as an array and add each element to the collection or alternatively add each element
7,535
public static < E > Matcher < ? super Collection < ? extends E > > hasSize ( Matcher < ? super Integer > size ) { return new IsCollectionWithSize < E > ( size ) ; }
Does collection size satisfy a given matcher?
7,536
private void updateParams ( ) { for ( int m = 0 ; m < documents . length ; m ++ ) { for ( int k = 0 ; k < K ; k ++ ) { thetasum [ m ] [ k ] += ( nd [ m ] [ k ] + alpha ) / ( ndsum [ m ] + K * alpha ) ; } } for ( int k = 0 ; k < K ; k ++ ) { for ( int w = 0 ; w < V ; w ++ ) { phisum [ k ] [ w ] += ( word_topic_matrix [ ...
Add to the statistics the values of theta and phi for the current state .
7,537
public static void hist ( float [ ] data , int fmax ) { float [ ] hist = new float [ data . length ] ; float hmax = 0 ; for ( int i = 0 ; i < data . length ; i ++ ) { hmax = Math . max ( data [ i ] , hmax ) ; } float shrink = fmax / hmax ; for ( int i = 0 ; i < data . length ; i ++ ) { hist [ i ] = shrink * data [ i ] ...
Print table of multinomial data
7,538
public void configure ( int iterations , int burnIn , int thinInterval , int sampleLag ) { ITERATIONS = iterations ; BURN_IN = burnIn ; THIN_INTERVAL = thinInterval ; SAMPLE_LAG = sampleLag ; }
Configure the gibbs sampler
7,539
public static String shadefloat ( float d , float max ) { int a = ( int ) Math . floor ( d * 10 / max + 0.5 ) ; if ( a > 10 || a < 0 ) { String x = lnf . format ( d ) ; a = 5 - x . length ( ) ; for ( int i = 0 ; i < a ; i ++ ) { x += " " ; } return "<" + x + ">" ; } return "[" + shades [ a ] + "]" ; }
create a string representation whose gray value appears as an indicator of magnitude cf . Hinton diagrams in statistics .
7,540
public long hash64 ( final byte [ ] data , int length , int seed ) { final long m = 0xc6a4a7935bd1e995L ; final int r = 47 ; long h = ( seed & 0xffffffffl ) ^ ( length * m ) ; int length8 = length / 8 ; for ( int i = 0 ; i < length8 ; i ++ ) { final int i8 = i * 8 ; long k = ( ( long ) data [ i8 + 0 ] & 0xff ) + ( ( ( ...
Generates 64 bit hash from byte array of the given length and seed .
7,541
private float weight ( int c1 , int c2 ) { float w ; float pc1 = wordProb . get ( c1 ) ; float pc2 = wordProb . get ( c2 ) ; if ( c1 == c2 ) { float pcc = getProb ( c1 , c1 ) ; w = clacW ( pcc , pc1 , pc2 ) ; } else { float pcc1 = getProb ( c1 , c2 ) ; float p1 = clacW ( pcc1 , pc1 , pc2 ) ; float pcc2 = getProb ( c2 ,...
total graph weight
7,542
public float calcL ( int c1 , int c2 ) { float L = 0 ; TIntIterator it = slots . iterator ( ) ; while ( it . hasNext ( ) ) { int k = it . next ( ) ; if ( k == c2 ) continue ; L += weight ( c1 , c2 , k ) ; } it = slots . iterator ( ) ; while ( it . hasNext ( ) ) { int k = it . next ( ) ; L -= getweight ( c1 , k ) ; L -=...
calculate the value L
7,543
private void addEdge ( int i , int j ) { if ( ! nodes . contains ( i ) ) { nodes . add ( i ) ; edges . put ( i , new HashSet < Integer > ( ) ) ; size ++ ; } else if ( ! edges . containsKey ( i ) ) { edges . put ( i , new HashSet < Integer > ( ) ) ; } if ( ! nodes . contains ( j ) ) { nodes . add ( j ) ; size ++ ; } edg...
i - > j
7,544
public void plus ( ISparseVector sv ) { if ( sv instanceof HashSparseVector ) { TIntFloatIterator it = ( ( HashSparseVector ) sv ) . data . iterator ( ) ; while ( it . hasNext ( ) ) { it . advance ( ) ; data . adjustOrPutValue ( it . key ( ) , it . value ( ) , it . value ( ) ) ; } } else if ( sv instanceof BinarySparse...
v + sv
7,545
public void SFFS ( ) throws Exception { int NumTemplate = Templates . length ; CurSet = new boolean [ NumTemplate ] ; LeftSet = new boolean [ NumTemplate ] ; for ( int i = 0 ; i < NumTemplate ; i ++ ) { CurSet [ i ] = false ; LeftSet [ i ] = true ; } Evaluate ( Templates , CurSet ) ; boolean continueDelete = false ; wh...
SFFS alg .
7,546
public GraphQLInterfaceType transform ( Consumer < Builder > builderConsumer ) { Builder builder = newInterface ( this ) ; builderConsumer . accept ( builder ) ; return builder . build ( ) ; }
This helps you transform the current GraphQLInterfaceType into another one by starting a builder with all the current values and allows you to transform it how you want .
7,547
@ SuppressWarnings ( "TypeParameterUnusedInFormals" ) public < T extends GraphQLType > T decorate ( GraphQLType objectType ) { GraphQLType out = objectType ; Stack < Class < ? > > wrappingStack = new Stack < > ( ) ; wrappingStack . addAll ( this . decoration ) ; while ( ! wrappingStack . isEmpty ( ) ) { Class < ? > cla...
This will decorate a graphql type with the original hierarchy of non null and list ness it originally contained in its definition type
7,548
public DataFetcher getDataFetcher ( GraphQLFieldsContainer parentType , GraphQLFieldDefinition fieldDefinition ) { return getDataFetcherImpl ( parentType , fieldDefinition , dataFetcherMap , systemDataFetcherMap ) ; }
Returns a data fetcher associated with a field within a container type
7,549
private CompletableFuture < NodeMultiZipper < ExecutionResultNode > > resolveNodes ( ExecutionContext executionContext , List < NodeMultiZipper < ExecutionResultNode > > unresolvedNodes ) { assertNotEmpty ( unresolvedNodes , "unresolvedNodes can't be empty" ) ; ExecutionResultNode commonRoot = unresolvedNodes . get ( 0...
all multizipper have the same root
7,550
public GraphQLFieldDefinition transform ( Consumer < Builder > builderConsumer ) { Builder builder = newFieldDefinition ( this ) ; builderConsumer . accept ( builder ) ; return builder . build ( ) ; }
This helps you transform the current GraphQLFieldDefinition into another one by starting a builder with all the current values and allows you to transform it how you want .
7,551
public static < U > SimpleInstrumentationContext < U > whenDispatched ( Consumer < CompletableFuture < U > > codeToRun ) { return new SimpleInstrumentationContext < > ( codeToRun , null ) ; }
Allows for the more fluent away to return an instrumentation context that runs the specified code on instrumentation step dispatch .
7,552
public static < U > SimpleInstrumentationContext < U > whenCompleted ( BiConsumer < U , Throwable > codeToRun ) { return new SimpleInstrumentationContext < > ( null , codeToRun ) ; }
Allows for the more fluent away to return an instrumentation context that runs the specified code on instrumentation step completion .
7,553
private void run ( final RunNode current ) { try { current . runnable . run ( ) ; } catch ( final Throwable thrown ) { reportFailure ( Thread . currentThread ( ) , thrown ) ; } }
Runs a single RunNode and deals with any thing it throws
7,554
private void runAll ( RunNode next ) { for ( ; ; ) { final RunNode current = next ; run ( current ) ; if ( ( next = current . get ( ) ) == null ) { if ( last . compareAndSet ( current , null ) ) { return ; } else { while ( ( next = current . get ( ) ) == null ) { } } } } }
Runs all the RunNodes starting with next
7,555
public List < GraphQLObjectType > findImplementations ( GraphQLSchema schema , GraphQLInterfaceType interfaceType ) { List < GraphQLObjectType > result = new ArrayList < > ( ) ; for ( GraphQLType type : schema . getAllTypesAsList ( ) ) { if ( ! ( type instanceof GraphQLObjectType ) ) { continue ; } GraphQLObjectType ob...
This method is deprecated due to a performance concern .
7,556
public static < T > CompletableFuture < T > toCompletableFuture ( T t ) { if ( t instanceof CompletionStage ) { return ( ( CompletionStage < T > ) t ) . toCompletableFuture ( ) ; } else { return CompletableFuture . completedFuture ( t ) ; } }
Turns an object T into a CompletableFuture if its not already
7,557
public Optional < GraphQLError > addAll ( Collection < SDLDefinition > definitions ) { for ( SDLDefinition definition : definitions ) { Optional < GraphQLError > error = add ( definition ) ; if ( error . isPresent ( ) ) { return error ; } } return Optional . empty ( ) ; }
Adds a a collections of definitions to the registry
7,558
public Optional < GraphQLError > add ( SDLDefinition definition ) { if ( definition instanceof ObjectTypeExtensionDefinition ) { ObjectTypeExtensionDefinition newEntry = ( ObjectTypeExtensionDefinition ) definition ; return defineExt ( objectTypeExtensions , newEntry , ObjectTypeExtensionDefinition :: getName ) ; } els...
Adds a definition to the registry
7,559
public < T extends TypeDefinition > List < T > getTypes ( Class < T > targetClass ) { return types . values ( ) . stream ( ) . filter ( targetClass :: isInstance ) . map ( targetClass :: cast ) . collect ( Collectors . toList ( ) ) ; }
Returns a list of types in the registry of that specified class
7,560
public < T extends TypeDefinition > Map < String , T > getTypesMap ( Class < T > targetClass ) { List < T > list = getTypes ( targetClass ) ; return FpKit . getByName ( list , TypeDefinition :: getName , FpKit . mergeFirst ( ) ) ; }
Returns a map of types in the registry of that specified class keyed by name
7,561
public List < ObjectTypeDefinition > getImplementationsOf ( InterfaceTypeDefinition targetInterface ) { List < ObjectTypeDefinition > objectTypeDefinitions = getTypes ( ObjectTypeDefinition . class ) ; return objectTypeDefinitions . stream ( ) . filter ( objectTypeDefinition -> { List < Type > implementsList = objectTy...
Returns the list of object types that implement the given interface type
7,562
@ SuppressWarnings ( "ConstantConditions" ) public boolean isPossibleType ( Type abstractType , Type possibleObjectType ) { if ( ! isInterfaceOrUnion ( abstractType ) ) { return false ; } if ( ! isObjectType ( possibleObjectType ) ) { return false ; } ObjectTypeDefinition targetObjectTypeDef = getType ( possibleObjectT...
Returns true of the abstract type is in implemented by the object type
7,563
public static ExecutionPath fromList ( List < ? > objects ) { assertNotNull ( objects ) ; ExecutionPath path = ExecutionPath . rootPath ( ) ; for ( Object object : objects ) { if ( object instanceof Number ) { path = path . segment ( ( ( Number ) object ) . intValue ( ) ) ; } else { path = path . segment ( String . val...
This will create an execution path from the list of objects
7,564
public static String printAst ( Node node ) { StringWriter sw = new StringWriter ( ) ; printAst ( sw , node ) ; return sw . toString ( ) ; }
This will pretty print the AST node in graphql language format
7,565
public static String printAstCompact ( Node node ) { StringWriter sw = new StringWriter ( ) ; printImpl ( sw , node , true ) ; return sw . toString ( ) ; }
This will print the Ast node in graphql language format in a compact manner with no new lines and comments stripped out of the text .
7,566
public GraphQLSchema transform ( Consumer < Builder > builderConsumer ) { Builder builder = newSchema ( this ) ; builderConsumer . accept ( builder ) ; return builder . build ( ) ; }
This helps you transform the current GraphQLSchema object into another one by starting a builder with all the current values and allows you to transform it how you want .
7,567
public static Builder newSchema ( GraphQLSchema existingSchema ) { return new Builder ( ) . query ( existingSchema . getQueryType ( ) ) . mutation ( existingSchema . getMutationType ( ) ) . subscription ( existingSchema . getSubscriptionType ( ) ) . codeRegistry ( existingSchema . getCodeRegistry ( ) ) . clearAdditiona...
This allows you to build a schema from an existing schema . It copies everything from the existing schema and then allows you to replace them .
7,568
public static < T > Map < String , T > getByName ( List < T > namedObjects , Function < T , String > nameFn , BinaryOperator < T > mergeFunc ) { return namedObjects . stream ( ) . collect ( Collectors . toMap ( nameFn , identity ( ) , mergeFunc , LinkedHashMap :: new ) ) ; }
From a list of named things get a map of them by name merging them according to the merge function
7,569
public static < T , NewKey > Map < NewKey , List < T > > groupingBy ( List < T > list , Function < T , NewKey > function ) { return list . stream ( ) . collect ( Collectors . groupingBy ( function , LinkedHashMap :: new , mapping ( Function . identity ( ) , Collectors . toList ( ) ) ) ) ; }
normal groupingBy but with LinkedHashMap
7,570
public static < T > Map < String , T > getByName ( List < T > namedObjects , Function < T , String > nameFn ) { return getByName ( namedObjects , nameFn , mergeFirst ( ) ) ; }
From a list of named things get a map of them by name merging them first one added
7,571
@ SuppressWarnings ( "unchecked" ) public static < T > Collection < T > toCollection ( Object iterableResult ) { if ( iterableResult . getClass ( ) . isArray ( ) ) { List < Object > collect = IntStream . range ( 0 , Array . getLength ( iterableResult ) ) . mapToObj ( i -> Array . get ( iterableResult , i ) ) . collect ...
Converts an object that should be an Iterable into a Collection efficiently leaving it alone if it is already is one . Useful when you want to get the size of something
7,572
public static < T > List < T > concat ( List < T > l1 , List < T > l2 ) { ArrayList < T > l = new ArrayList < > ( l1 ) ; l . addAll ( l2 ) ; l . trimToSize ( ) ; return l ; }
Concatenates two lists into one
7,573
public static < T > List < T > valuesToList ( Map < ? , T > map ) { return new ArrayList < > ( map . values ( ) ) ; }
quickly turn a map of values into its list equivalent
7,574
public static TypeRuntimeWiring newTypeWiring ( String typeName , UnaryOperator < Builder > builderFunction ) { return builderFunction . apply ( newTypeWiring ( typeName ) ) . build ( ) ; }
This form allows a lambda to be used as the builder
7,575
public CacheControl hint ( DataFetchingEnvironment dataFetchingEnvironment , Integer maxAge , Scope scope ) { assertNotNull ( dataFetchingEnvironment ) ; assertNotNull ( scope ) ; hint ( dataFetchingEnvironment . getExecutionStepInfo ( ) . getPath ( ) , maxAge , scope ) ; return this ; }
This creates a cache control hint for the specified field being fetched
7,576
public CacheControl hint ( DataFetchingEnvironment dataFetchingEnvironment , Integer maxAge ) { hint ( dataFetchingEnvironment , maxAge , Scope . PUBLIC ) ; return this ; }
This creates a cache control hint for the specified field being fetched with a PUBLIC scope
7,577
public CacheControl hint ( DataFetchingEnvironment dataFetchingEnvironment , Scope scope ) { return hint ( dataFetchingEnvironment , null , scope ) ; }
This creates a cache control hint for the specified field being fetched with a specified scope
7,578
public GraphQLUnionType transform ( Consumer < Builder > builderConsumer ) { Builder builder = newUnionType ( this ) ; builderConsumer . accept ( builder ) ; return builder . build ( ) ; }
This helps you transform the current GraphQLUnionType into another one by starting a builder with all the current values and allows you to transform it how you want .
7,579
public SimpleFieldValidation addRule ( ExecutionPath fieldPath , BiFunction < FieldAndArguments , FieldValidationEnvironment , Optional < GraphQLError > > rule ) { rules . put ( fieldPath , rule ) ; return this ; }
Adds the rule against the field address path . If the rule returns an error it will be added to the list of errors
7,580
protected CompletableFuture < ExecutionResult > completeValueForObject ( ExecutionContext executionContext , ExecutionStrategyParameters parameters , GraphQLObjectType resolvedObjectType , Object result ) { ExecutionStepInfo executionStepInfo = parameters . getExecutionStepInfo ( ) ; FieldCollectorParameters collectorP...
Called to turn an java object value into an graphql object value
7,581
protected ExecutionStepInfo createExecutionStepInfo ( ExecutionContext executionContext , ExecutionStrategyParameters parameters , GraphQLFieldDefinition fieldDefinition , GraphQLObjectType fieldContainer ) { GraphQLOutputType fieldType = fieldDefinition . getType ( ) ; List < Argument > fieldArgs = parameters . getFie...
Builds the type info hierarchy for the current field
7,582
public SourceAndLine getSourceAndLineFromOverallLine ( int overallLineNumber ) { SourceAndLine sourceAndLine = new SourceAndLine ( ) ; if ( sourceParts . isEmpty ( ) ) { return sourceAndLine ; } SourcePart currentPart ; if ( currentIndex >= sourceParts . size ( ) ) { currentPart = sourceParts . get ( sourceParts . size...
This returns the source name and line number given an overall line number
7,583
public < T > T validate ( ExecutionPath path , T result ) throws NonNullableFieldWasNullException { if ( result == null ) { if ( executionStepInfo . isNonNullType ( ) ) { NonNullableFieldWasNullException nonNullException = new NonNullableFieldWasNullException ( executionStepInfo , path ) ; executionContext . addError (...
Called to check that a value is non null if the type requires it to be non null
7,584
public static boolean isLeaf ( GraphQLType type ) { GraphQLUnmodifiedType unmodifiedType = unwrapAll ( type ) ; return unmodifiedType instanceof GraphQLScalarType || unmodifiedType instanceof GraphQLEnumType ; }
Returns true if the given type is a leaf type that it cant contain any more fields
7,585
public static boolean isInput ( GraphQLType type ) { GraphQLUnmodifiedType unmodifiedType = unwrapAll ( type ) ; return unmodifiedType instanceof GraphQLScalarType || unmodifiedType instanceof GraphQLEnumType || unmodifiedType instanceof GraphQLInputObjectType ; }
Returns true if the given type is an input type
7,586
public static GraphQLType unwrapOne ( GraphQLType type ) { if ( isNonNull ( type ) ) { return ( ( GraphQLNonNull ) type ) . getWrappedType ( ) ; } else if ( isList ( type ) ) { return ( ( GraphQLList ) type ) . getWrappedType ( ) ; } return type ; }
Unwraps one layer of the type or just returns the type again if its not a wrapped type
7,587
public static GraphQLUnmodifiedType unwrapAll ( GraphQLType type ) { while ( true ) { if ( isNotWrapped ( type ) ) { return ( GraphQLUnmodifiedType ) type ; } type = unwrapOne ( type ) ; } }
Unwraps all layers of the type or just returns the type again if its not a wrapped type
7,588
public String getResultKey ( ) { Field singleField = getSingleField ( ) ; if ( singleField . getAlias ( ) != null ) { return singleField . getAlias ( ) ; } return singleField . getName ( ) ; }
Returns the key of this MergedField for the overall result . This is either an alias or the field name .
7,589
public ExecutionResult toExecutionResult ( ) { ExecutionResult executionResult = new ExecutionResultImpl ( this ) ; if ( ! this . getUnderlyingErrors ( ) . isEmpty ( ) ) { executionResult = new ExecutionResultImpl ( this . getUnderlyingErrors ( ) ) ; } return executionResult ; }
This is useful for turning this abort signal into an execution result which is an error state with the underlying errors in it .
7,590
public Document createSchemaDefinition ( ExecutionResult introspectionResult ) { Map < String , Object > introspectionResultMap = introspectionResult . getData ( ) ; return createSchemaDefinition ( introspectionResultMap ) ; }
Returns a IDL Document that represents the schema as defined by the introspection execution result
7,591
@ SuppressWarnings ( "unchecked" ) public Document createSchemaDefinition ( Map < String , Object > introspectionResult ) { assertTrue ( introspectionResult . get ( "__schema" ) != null , "__schema expected" ) ; Map < String , Object > schema = ( Map < String , Object > ) introspectionResult . get ( "__schema" ) ; Map ...
Returns a IDL Document that reprSesents the schema as defined by the introspection result map
7,592
static < T , E extends GraphQLError > void checkNamedUniqueness ( List < GraphQLError > errors , List < T > listOfNamedThings , Function < T , String > namer , BiFunction < String , T , E > errorFunction ) { Set < String > names = new LinkedHashSet < > ( ) ; listOfNamedThings . forEach ( thing -> { String name = namer ...
A simple function that takes a list of things asks for their names and checks that the names are unique within that list . If not it calls the error handler function
7,593
public static String assertValidName ( String name ) { if ( name != null && ! name . isEmpty ( ) && name . matches ( "[_A-Za-z][_0-9A-Za-z]*" ) ) { return name ; } throw new AssertException ( String . format ( invalidNameErrorMessage , name ) ) ; }
Validates that the Lexical token name matches the current spec . currently non null non empty
7,594
public Map < String , Object > snapshotTracingData ( ) { Map < String , Object > traceMap = new LinkedHashMap < > ( ) ; traceMap . put ( "version" , 1L ) ; traceMap . put ( "startTime" , rfc3339 ( startRequestTime ) ) ; traceMap . put ( "endTime" , rfc3339 ( Instant . now ( ) ) ) ; traceMap . put ( "duration" , System ...
This will snapshot this tracing and return a map of the results
7,595
public GraphQLEnumType transform ( Consumer < Builder > builderConsumer ) { Builder builder = newEnum ( this ) ; builderConsumer . accept ( builder ) ; return builder . build ( ) ; }
This helps you transform the current GraphQLEnumType into another one by starting a builder with all the current values and allows you to transform it how you want .
7,596
public static DiffSet diffSet ( Map < String , Object > introspectionOld , Map < String , Object > introspectionNew ) { return new DiffSet ( introspectionOld , introspectionNew ) ; }
Creates a diff set out of the result of 2 introspection queries .
7,597
public static DiffSet diffSet ( GraphQLSchema schemaOld , GraphQLSchema schemaNew ) { Map < String , Object > introspectionOld = introspect ( schemaOld ) ; Map < String , Object > introspectionNew = introspect ( schemaNew ) ; return diffSet ( introspectionOld , introspectionNew ) ; }
Creates a diff set out of the result of 2 schemas .
7,598
public GraphQLArgument transform ( Consumer < Builder > builderConsumer ) { Builder builder = newArgument ( this ) ; builderConsumer . accept ( builder ) ; return builder . build ( ) ; }
This helps you transform the current GraphQLArgument into another one by starting a builder with all the current values and allows you to transform it how you want .
7,599
@ SuppressWarnings ( "unchecked" ) public int diffSchema ( DiffSet diffSet , DifferenceReporter reporter ) { CountingReporter countingReporter = new CountingReporter ( reporter ) ; diffSchemaImpl ( diffSet , countingReporter ) ; return countingReporter . breakingCount ; }
This will perform a difference on the two schemas . The reporter callback interface will be called when differences are encountered .