idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
151,100
public static void ensureXPathNotNull ( Node node , String expression ) { if ( node == null ) { throw LOG . unableToFindXPathExpression ( expression ) ; } }
Ensure that the node is not null .
151,101
public static void ensureXPathNotEmpty ( NodeList nodeList , String expression ) { if ( nodeList == null || nodeList . getLength ( ) == 0 ) { throw LOG . unableToFindXPathExpression ( expression ) ; } }
Ensure that the nodeList is either null or empty .
151,102
public String getCanonicalTypeName ( Object object ) { ensureNotNull ( "object" , object ) ; for ( TypeDetector typeDetector : typeDetectors ) { if ( typeDetector . canHandle ( object ) ) { return typeDetector . detectType ( object ) ; } } throw LOG . unableToDetectCanonicalType ( object ) ; }
Identifies the canonical type of an object heuristically .
151,103
protected Transformer getTransformer ( ) { TransformerFactory transformerFactory = domXmlDataFormat . getTransformerFactory ( ) ; try { Transformer transformer = transformerFactory . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . ENCODING , "UTF-8" ) ; transformer . setOutputProperty ( OutputKeys ....
Returns a configured transformer to write XML .
151,104
public static Class < ? > loadClass ( String classname , DataFormat < ? > dataFormat ) { ClassLoader cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( cl != null ) { LOG . tryLoadingClass ( classname , cl ) ; try { return cl . loadClass ( classname ) ; } catch ( Exception e ) { } } cl = dataFormat . ge...
Used by dataformats if they need to load a class
151,105
public static String getExtension ( String language ) { language = language . toLowerCase ( ) ; if ( "ecmascript" . equals ( language ) ) { language = "javascript" ; } return extensions . get ( language ) ; }
Get file extension for script language .
151,106
public static String get ( String language ) { language = language . toLowerCase ( ) ; if ( "ecmascript" . equals ( language ) ) { language = "javascript" ; } String extension = extensions . get ( language ) ; if ( extension == null ) { return null ; } else { return loadScriptEnv ( language , extension ) ; } }
Get the spin scripting environment
151,107
protected Integer getCorrectIndex ( Integer index ) { Integer size = jsonNode . size ( ) ; Integer newIndex = index ; if ( index < 0 ) { newIndex = size + index ; } if ( newIndex < 0 ) { throw LOG . indexOutOfBounds ( index , size ) ; } if ( index > size ) { throw LOG . indexOutOfBounds ( index , size ) ; } return newI...
fetch correct array index if index is less than 0
151,108
public void setNamespace ( String prefix , String namespaceURI ) { ensureNotNull ( "Prefix" , prefix ) ; ensureNotNull ( "Namespace URI" , namespaceURI ) ; namespaces . put ( prefix , namespaceURI ) ; }
Maps a single prefix uri pair as namespace .
151,109
public static < T extends Spin < ? > > T S ( Object input , DataFormat < T > format ) { return SpinFactory . INSTANCE . createSpin ( input , format ) ; }
Creates a spin wrapper for a data input of a given data format .
151,110
public static SpinXmlElement XML ( Object input ) { return SpinFactory . INSTANCE . createSpin ( input , DataFormats . xml ( ) ) ; }
Creates a spin wrapper for a data input . The data format of the input is assumed to be XML .
151,111
public static SpinJsonNode JSON ( Object input ) { return SpinFactory . INSTANCE . createSpin ( input , DataFormats . json ( ) ) ; }
Creates a spin wrapper for a data input . The data format of the input is assumed to be JSON .
151,112
public synchronized void stop ( ) throws DatastoreEmulatorException { stopEmulatorInternal ( ) ; if ( state != State . STOPPED ) { state = State . STOPPED ; if ( projectDirectory != null ) { try { Process process = new ProcessBuilder ( "rm" , "-r" , projectDirectory . getAbsolutePath ( ) ) . start ( ) ; if ( process . ...
Stops the emulator . Multiple calls are allowed .
151,113
private void sendEmptyRequest ( String path , String method ) throws DatastoreEmulatorException { HttpURLConnection connection = null ; try { URL url = new URL ( this . host + path ) ; connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . setDoOutput ( true ) ; connection . setRequestMethod ( metho...
Send an empty request using a standard HTTP connection .
151,114
public InputStream call ( String methodName , MessageLite request ) throws DatastoreException { logger . fine ( "remote datastore call " + methodName ) ; long startTime = System . currentTimeMillis ( ) ; try { HttpResponse httpResponse ; try { rpcCount . incrementAndGet ( ) ; ProtoHttpContent payload = new ProtoHttpCon...
Makes an RPC call using the client . Logs how long it took and any exceptions .
151,115
private void addGreeting ( String guestbookName , String user , String message ) throws DatastoreException { Entity . Builder greeting = Entity . newBuilder ( ) ; greeting . setKey ( makeKey ( GUESTBOOK_KIND , guestbookName , GREETING_KIND ) ) ; greeting . getMutableProperties ( ) . put ( USER_PROPERTY , makeValue ( us...
Add a greeting to the specified guestbook .
151,116
private void listGreetings ( String guestbookName ) throws DatastoreException { Query . Builder query = Query . newBuilder ( ) ; query . addKindBuilder ( ) . setName ( GREETING_KIND ) ; query . setFilter ( makeFilter ( KEY_PROPERTY , PropertyFilter . Operator . HAS_ANCESTOR , makeValue ( makeKey ( GUESTBOOK_KIND , gues...
List the greetings in the specified guestbook .
151,117
private Key insert ( Entity entity ) throws DatastoreException { CommitRequest req = CommitRequest . newBuilder ( ) . addMutations ( Mutation . newBuilder ( ) . setInsert ( entity ) ) . setMode ( CommitRequest . Mode . NON_TRANSACTIONAL ) . build ( ) ; return datastore . commit ( req ) . getMutationResults ( 0 ) . getK...
Insert an entity into the datastore .
151,118
private List < Entity > runQuery ( Query query ) throws DatastoreException { RunQueryRequest . Builder request = RunQueryRequest . newBuilder ( ) ; request . setQuery ( query ) ; RunQueryResponse response = datastore . runQuery ( request . build ( ) ) ; if ( response . getBatch ( ) . getMoreResults ( ) == QueryResultBa...
Run a query on the datastore .
151,119
private void validateFilter ( Filter filter ) throws IllegalArgumentException { switch ( filter . getFilterTypeCase ( ) ) { case COMPOSITE_FILTER : for ( Filter subFilter : filter . getCompositeFilter ( ) . getFiltersList ( ) ) { validateFilter ( subFilter ) ; } break ; case PROPERTY_FILTER : if ( UNSUPPORTED_OPERATORS...
Validates that we only have allowable filters .
151,120
private void validateQuery ( Query query ) throws IllegalArgumentException { if ( query . getKindCount ( ) != 1 ) { throw new IllegalArgumentException ( "Query must have exactly one kind." ) ; } if ( query . getOrderCount ( ) != 0 ) { throw new IllegalArgumentException ( "Query cannot have any sort orders." ) ; } if ( ...
Verifies that the given query can be properly scattered .
151,121
private List < Key > getScatterKeys ( int numSplits , Query query , PartitionId partition , Datastore datastore ) throws DatastoreException { Query . Builder scatterPointQuery = createScatterQuery ( query , numSplits ) ; List < Key > keySplits = new ArrayList < Key > ( ) ; QueryResultBatch batch ; do { RunQueryRequest ...
Gets a list of split keys given a desired number of splits .
151,122
private Query . Builder createScatterQuery ( Query query , int numSplits ) { Query . Builder scatterPointQuery = Query . newBuilder ( ) ; scatterPointQuery . addAllKind ( query . getKindList ( ) ) ; scatterPointQuery . addOrder ( DatastoreHelper . makeOrder ( DatastoreHelper . SCATTER_PROPERTY_NAME , Direction . ASCEND...
Creates a scatter query from the given user query
151,123
private Iterable < Key > getSplitKey ( List < Key > keys , int numSplits ) { if ( keys . size ( ) < numSplits - 1 ) { return keys ; } double numKeysPerSplit = Math . max ( 1.0 , ( ( double ) keys . size ( ) ) / ( numSplits - 1 ) ) ; List < Key > keysList = new ArrayList < Key > ( numSplits - 1 ) ; for ( int i = 1 ; i <...
Given a list of keys and a number of splits find the keys to split on .
151,124
public HttpRequestFactory makeClient ( DatastoreOptions options ) { Credential credential = options . getCredential ( ) ; HttpTransport transport = options . getTransport ( ) ; if ( transport == null ) { transport = credential == null ? new NetHttpTransport ( ) : credential . getTransport ( ) ; transport = transport ==...
Constructs a Google APIs HTTP client with the associated credentials .
151,125
String buildProjectEndpoint ( DatastoreOptions options ) { if ( options . getProjectEndpoint ( ) != null ) { return options . getProjectEndpoint ( ) ; } String projectId = checkNotNull ( options . getProjectId ( ) ) ; if ( options . getHost ( ) != null ) { return validateUrl ( String . format ( "https://%s/%s/projects/...
Build a valid datastore URL .
151,126
private static synchronized StreamHandler getStreamHandler ( ) { if ( methodHandler == null ) { methodHandler = new ConsoleHandler ( ) ; methodHandler . setFormatter ( new Formatter ( ) { public String format ( LogRecord record ) { return record . getMessage ( ) + "\n" ; } } ) ; methodHandler . setLevel ( Level . FINE ...
running in App Engine
151,127
public static Credential getServiceAccountCredential ( String serviceAccountId , String privateKeyFile , Collection < String > serviceAccountScopes ) throws GeneralSecurityException , IOException { return getCredentialBuilderWithoutPrivateKey ( serviceAccountId , serviceAccountScopes ) . setServiceAccountPrivateKeyFrom...
Constructs credentials for the given account and key file .
151,128
public static PropertyOrder . Builder makeOrder ( String property , PropertyOrder . Direction direction ) { return PropertyOrder . newBuilder ( ) . setProperty ( makePropertyReference ( property ) ) . setDirection ( direction ) ; }
Make a sort order for use in a query .
151,129
public static Filter . Builder makeAncestorFilter ( Key ancestor ) { return makeFilter ( DatastoreHelper . KEY_PROPERTY_NAME , PropertyFilter . Operator . HAS_ANCESTOR , makeValue ( ancestor ) ) ; }
Makes an ancestor filter .
151,130
public static Filter . Builder makeAndFilter ( Iterable < Filter > subfilters ) { return Filter . newBuilder ( ) . setCompositeFilter ( CompositeFilter . newBuilder ( ) . addAllFilters ( subfilters ) . setOp ( CompositeFilter . Operator . AND ) ) ; }
Make a composite filter from the given sub - filters using AND to combine filters .
151,131
public static Value . Builder makeValue ( Value value1 , Value value2 , Value ... rest ) { ArrayValue . Builder arrayValue = ArrayValue . newBuilder ( ) ; arrayValue . addValues ( value1 ) ; arrayValue . addValues ( value2 ) ; arrayValue . addAllValues ( Arrays . asList ( rest ) ) ; return Value . newBuilder ( ) . setA...
Make a list value containing the specified values .
151,132
public static Value . Builder makeValue ( Date date ) { return Value . newBuilder ( ) . setTimestampValue ( toTimestamp ( date . getTime ( ) * 1000L ) ) ; }
Make a timestamp value given a date .
151,133
public static < T extends Comparable < ? super T > > List < T > sortInplace ( List < T > list ) { Collections . sort ( list ) ; return list ; }
Sorts the specified list itself into ascending order according to the natural ordering of its elements .
151,134
public static < T , C extends Comparable < ? super C > > List < T > sortInplaceBy ( List < T > list , final Functions . Function1 < ? super T , C > key ) { if ( key == null ) throw new NullPointerException ( "key" ) ; Collections . sort ( list , new KeyComparator < T , C > ( key ) ) ; return list ; }
Sorts the specified list itself according to the order induced by applying a key function to each element which yields a comparable criteria .
151,135
public static < T > List < T > reverseView ( List < T > list ) { return Lists . reverse ( list ) ; }
Provides a reverse view on the given list which is especially useful to traverse a list backwards in a for - each loop . The list itself is not modified by calling this method .
151,136
public void set ( Object receiver , String fieldName , Object value ) throws SecurityException , NoSuchFieldException , IllegalArgumentException , IllegalAccessException { Preconditions . checkNotNull ( receiver , "receiver" ) ; Preconditions . checkNotNull ( fieldName , "fieldName" ) ; Class < ? extends Object > clazz...
Sets the given value on an the receivers s accessible field with the given name .
151,137
@ SuppressWarnings ( "unchecked" ) public < T > T get ( Object receiver , String fieldName ) throws SecurityException , NoSuchFieldException , IllegalArgumentException , IllegalAccessException { Preconditions . checkNotNull ( receiver , "receiver" ) ; Preconditions . checkNotNull ( fieldName , "fieldName" ) ; Class < ?...
Retrieves the value of the given accessible field of the given receiver .
151,138
public void append ( Object object , String indentation ) { append ( object , indentation , segments . size ( ) ) ; }
Add the string representation of the given object to this sequence . The given indentation will be prepended to each line except the first one if the object has a multi - line string representation .
151,139
public void append ( String str , String indentation ) { if ( indentation . isEmpty ( ) ) { append ( str ) ; } else if ( str != null ) append ( indentation , str , segments . size ( ) ) ; }
Add the given string to this sequence . The given indentation will be prepended to each line except the first one if the object has a multi - line string representation .
151,140
protected void append ( Object object , String indentation , int index ) { if ( indentation . length ( ) == 0 ) { append ( object , index ) ; return ; } if ( object == null ) return ; if ( object instanceof String ) { append ( indentation , ( String ) object , index ) ; } else if ( object instanceof StringConcatenation...
Add the string representation of the given object to this sequence at the given index . The given indentation will be prepended to each line except the first one if the object has a multi - line string representation .
151,141
public void appendImmediate ( Object object , String indentation ) { for ( int i = segments . size ( ) - 1 ; i >= 0 ; i -- ) { String segment = segments . get ( i ) ; for ( int j = 0 ; j < segment . length ( ) ; j ++ ) { if ( ! WhitespaceMatcher . isWhitespace ( segment . charAt ( j ) ) ) { append ( object , indentatio...
Add the string representation of the given object to this sequence immediately . That is all the trailing whitespace of this sequence will be ignored and the string is appended directly after the last segment that contains something besides whitespace . The given indentation will be prepended to each line except the fi...
151,142
public void newLineIfNotEmpty ( ) { for ( int i = segments . size ( ) - 1 ; i >= 0 ; i -- ) { String segment = segments . get ( i ) ; if ( lineDelimiter . equals ( segment ) ) { segments . subList ( i + 1 , segments . size ( ) ) . clear ( ) ; cachedToString = null ; return ; } for ( int j = 0 ; j < segment . length ( )...
Add a newline to this sequence according to the configured lineDelimiter if the last line contains something besides whitespace .
151,143
protected List < String > splitLinesAndNewLines ( String text ) { if ( text == null ) return Collections . emptyList ( ) ; int idx = initialSegmentSize ( text ) ; if ( idx == text . length ( ) ) { return Collections . singletonList ( text ) ; } return continueSplitting ( text , idx ) ; }
Return a list of segments where each segment is either the content of a line in the given text or a line - break according to the configured delimiter . Existing line - breaks in the text will be replaced by this s instances delimiter .
151,144
public static < K , V > Pair < K , V > of ( K k , V v ) { return new Pair < K , V > ( k , v ) ; }
Creates a new instance with the given key and value . May be used instead of the constructor for convenience reasons .
151,145
public static < P1 > Procedure0 curry ( final Procedure1 < ? super P1 > procedure , final P1 argument ) { if ( procedure == null ) throw new NullPointerException ( "procedure" ) ; return new Procedure0 ( ) { public void apply ( ) { procedure . apply ( argument ) ; } } ; }
Curries a procedure that takes one argument .
151,146
public static < P1 , P2 > Procedure1 < P2 > curry ( final Procedure2 < ? super P1 , ? super P2 > procedure , final P1 argument ) { if ( procedure == null ) throw new NullPointerException ( "procedure" ) ; return new Procedure1 < P2 > ( ) { public void apply ( P2 p ) { procedure . apply ( argument , p ) ; } } ; }
Curries a procedure that takes two arguments .
151,147
public static < P1 , P2 , P3 > Procedure2 < P2 , P3 > curry ( final Procedure3 < ? super P1 , ? super P2 , ? super P3 > procedure , final P1 argument ) { if ( procedure == null ) throw new NullPointerException ( "procedure" ) ; return new Procedure2 < P2 , P3 > ( ) { public void apply ( P2 p2 , P3 p3 ) { procedure . ap...
Curries a procedure that takes three arguments .
151,148
public static < P1 , P2 , P3 , P4 , P5 > Procedure4 < P2 , P3 , P4 , P5 > curry ( final Procedure5 < ? super P1 , ? super P2 , ? super P3 , ? super P4 , ? super P5 > procedure , final P1 argument ) { if ( procedure == null ) throw new NullPointerException ( "procedure" ) ; return new Procedure4 < P2 , P3 , P4 , P5 > ( ...
Curries a procedure that takes five arguments .
151,149
public Path getParent ( ) { if ( ! isAbsolute ( ) ) throw new IllegalStateException ( "path is not absolute: " + toString ( ) ) ; if ( segments . isEmpty ( ) ) return null ; return new Path ( segments . subList ( 0 , segments . size ( ) - 1 ) , true ) ; }
Returns the parent of this path or null if this path is the root path .
151,150
public Path relativize ( Path other ) { if ( other . isAbsolute ( ) != isAbsolute ( ) ) throw new IllegalArgumentException ( "This path and the given path are not both absolute or both relative: " + toString ( ) + " | " + other . toString ( ) ) ; if ( startsWith ( other ) ) { return internalRelativize ( this , other ) ...
Constructs a relative path between this path and a given path .
151,151
@ Inline ( value = "$1.put($2.getKey(), $2.getValue())" , statementExpression = true ) public static < K , V > V operator_add ( Map < K , V > map , Pair < ? extends K , ? extends V > entry ) { return map . put ( entry . getKey ( ) , entry . getValue ( ) ) ; }
Add the given pair into the map .
151,152
@ Inline ( value = "$1.putAll($2)" , statementExpression = true ) public static < K , V > void operator_add ( Map < K , V > outputMap , Map < ? extends K , ? extends V > inputMap ) { outputMap . putAll ( inputMap ) ; }
Add the given entries of the input map into the output map .
151,153
@ Inline ( value = "$3.union($1, $4.singletonMap($2.getKey(), $2.getValue()))" , imported = { MapExtensions . class , Collections . class } ) public static < K , V > Map < K , V > operator_plus ( Map < K , V > left , final Pair < ? extends K , ? extends V > right ) { return union ( left , Collections . singletonMap ( r...
Add the given pair to a given map for obtaining a new map .
151,154
@ Inline ( value = "$3.union($1, $2)" , imported = MapExtensions . class ) public static < K , V > Map < K , V > operator_plus ( Map < K , V > left , Map < ? extends K , ? extends V > right ) { return union ( left , right ) ; }
Merge the two maps .
151,155
@ Inline ( value = "$1.remove($2)" , statementExpression = true ) public static < K , V > V operator_remove ( Map < K , V > map , K key ) { return map . remove ( key ) ; }
Remove a key from the given map .
151,156
@ Inline ( value = "$1.remove($2.getKey(), $2.getValue())" , statementExpression = true ) public static < K , V > boolean operator_remove ( Map < K , V > map , Pair < ? extends K , ? extends V > entry ) { final K key = entry . getKey ( ) ; final V storedValue = map . get ( entry . getKey ( ) ) ; if ( ! Objects . equal ...
Remove the given pair into the map .
151,157
public static < K , V > void operator_remove ( Map < K , V > map , Iterable < ? super K > keysToRemove ) { for ( final Object key : keysToRemove ) { map . remove ( key ) ; } }
Remove pairs with the given keys from the map .
151,158
public static < K , V > Map < K , V > operator_minus ( Map < K , V > left , final Pair < ? extends K , ? extends V > right ) { return Maps . filterEntries ( left , new Predicate < Entry < K , V > > ( ) { public boolean apply ( Entry < K , V > input ) { return ! Objects . equal ( input . getKey ( ) , right . getKey ( ) ...
Remove the given pair from a given map for obtaining a new map .
151,159
public static < K , V > Map < K , V > operator_minus ( Map < K , V > map , final K key ) { return Maps . filterKeys ( map , new Predicate < K > ( ) { public boolean apply ( K input ) { return ! Objects . equal ( input , key ) ; } } ) ; }
Replies the elements of the given map except the pair with the given key .
151,160
public static < K , V > Map < K , V > operator_minus ( Map < K , V > left , final Map < ? extends K , ? extends V > right ) { return Maps . filterEntries ( left , new Predicate < Entry < K , V > > ( ) { public boolean apply ( Entry < K , V > input ) { final V value = right . get ( input . getKey ( ) ) ; if ( value == n...
Replies the elements of the left map without the pairs in the right map . If the pair s values differ from the value within the map the map entry is not removed .
151,161
public static < K , V > Map < K , V > operator_minus ( Map < K , V > map , final Iterable < ? > keys ) { return Maps . filterKeys ( map , new Predicate < K > ( ) { public boolean apply ( K input ) { return ! Iterables . contains ( keys , input ) ; } } ) ; }
Replies the elements of the given map except the pairs with the given keys .
151,162
@ Inline ( value = "(new $3<$5, $6>($1, $2))" , imported = UnmodifiableMergingMapView . class , constantExpression = true ) public static < K , V > Map < K , V > union ( Map < ? extends K , ? extends V > left , Map < ? extends K , ? extends V > right ) { return new UnmodifiableMergingMapView < K , V > ( left , right ) ...
Merge the given maps .
151,163
public static < P1 , RESULT > Function0 < RESULT > curry ( final Function1 < ? super P1 , ? extends RESULT > function , final P1 argument ) { if ( function == null ) throw new NullPointerException ( "function" ) ; return new Function0 < RESULT > ( ) { public RESULT apply ( ) { return function . apply ( argument ) ; } }...
Curries a function that takes one argument .
151,164
public static < P1 , P2 , RESULT > Function1 < P2 , RESULT > curry ( final Function2 < ? super P1 , ? super P2 , ? extends RESULT > function , final P1 argument ) { if ( function == null ) throw new NullPointerException ( "function" ) ; return new Function1 < P2 , RESULT > ( ) { public RESULT apply ( P2 p ) { return fu...
Curries a function that takes two arguments .
151,165
public static < P1 , P2 , P3 , RESULT > Function2 < P2 , P3 , RESULT > curry ( final Function3 < ? super P1 , ? super P2 , ? super P3 , ? extends RESULT > function , final P1 argument ) { if ( function == null ) throw new NullPointerException ( "function" ) ; return new Function2 < P2 , P3 , RESULT > ( ) { public RESUL...
Curries a function that takes three arguments .
151,166
public static < P1 , P2 , P3 , P4 , RESULT > Function3 < P2 , P3 , P4 , RESULT > curry ( final Function4 < ? super P1 , ? super P2 , ? super P3 , ? super P4 , ? extends RESULT > function , final P1 argument ) { if ( function == null ) throw new NullPointerException ( "function" ) ; return new Function3 < P2 , P3 , P4 ,...
Curries a function that takes four arguments .
151,167
public static < T > Iterable < T > filterNull ( Iterable < T > unfiltered ) { return Iterables . filter ( unfiltered , Predicates . notNull ( ) ) ; }
Returns a new iterable filtering any null references .
151,168
public static < T extends Comparable < ? super T > > List < T > sort ( Iterable < T > iterable ) { List < T > asList = Lists . newArrayList ( iterable ) ; if ( iterable instanceof SortedSet < ? > ) { if ( ( ( SortedSet < T > ) iterable ) . comparator ( ) == null ) { return asList ; } } return ListExtensions . sortInpla...
Creates a sorted list that contains the items of the given iterable . The resulting list is in ascending order according to the natural ordering of the elements in the iterable .
151,169
public static < T > List < T > sortWith ( Iterable < T > iterable , Comparator < ? super T > comparator ) { return ListExtensions . sortInplace ( Lists . newArrayList ( iterable ) , comparator ) ; }
Creates a sorted list that contains the items of the given iterable . The resulting list is sorted according to the order induced by the specified comparator .
151,170
public static < T , C extends Comparable < ? super C > > List < T > sortBy ( Iterable < T > iterable , final Functions . Function1 < ? super T , C > key ) { return ListExtensions . sortInplaceBy ( Lists . newArrayList ( iterable ) , key ) ; }
Creates a sorted list that contains the items of the given iterable . The resulting list is sorted according to the order induced by applying a key function to each element which yields a comparable criteria .
151,171
private static Object checkComponentType ( Object array , Class < ? > expectedComponentType ) { Class < ? > actualComponentType = array . getClass ( ) . getComponentType ( ) ; if ( ! expectedComponentType . isAssignableFrom ( actualComponentType ) ) { throw new ArrayStoreException ( String . format ( "The expected comp...
Checks the component type of the given array against the expected component type .
151,172
@ GwtIncompatible ( "Class.getDeclaredFields" ) public ToStringBuilder addDeclaredFields ( ) { Field [ ] fields = instance . getClass ( ) . getDeclaredFields ( ) ; for ( Field field : fields ) { addField ( field ) ; } return this ; }
Adds all fields declared directly in the object s class to the output
151,173
@ GwtIncompatible ( "Class.getDeclaredFields" ) public ToStringBuilder addAllFields ( ) { List < Field > fields = getAllDeclaredFields ( instance . getClass ( ) ) ; for ( Field field : fields ) { addField ( field ) ; } return this ; }
Adds all fields declared in the object s class and its superclasses to the output .
151,174
public static < T > Iterator < T > filterNull ( Iterator < T > unfiltered ) { return Iterators . filter ( unfiltered , Predicates . notNull ( ) ) ; }
Returns a new iterator filtering any null references .
151,175
public static < T > List < T > toList ( Iterator < ? extends T > iterator ) { return Lists . newArrayList ( iterator ) ; }
Returns a list that contains all the entries of the given iterator in the same order .
151,176
public static < T > Set < T > toSet ( Iterator < ? extends T > iterator ) { return Sets . newLinkedHashSet ( toIterable ( iterator ) ) ; }
Returns a set that contains all the unique entries of the given iterator in the order of their appearance . The result set is a copy of the iterator with stable order .
151,177
public HomekitRoot createBridge ( HomekitAuthInfo authInfo , String label , String manufacturer , String model , String serialNumber ) throws IOException { HomekitRoot root = new HomekitRoot ( label , http , localAddress , authInfo ) ; root . addAccessory ( new HomekitBridge ( label , serialNumber , model , manufacture...
Creates a bridge accessory capable of holding multiple child accessories . This has the advantage over multiple standalone accessories of only requiring a single pairing from iOS for the bridge .
151,178
protected CompletableFuture < JsonObjectBuilder > makeBuilder ( int instanceId ) { CompletableFuture < T > futureValue = getValue ( ) ; if ( futureValue == null ) { logger . error ( "Could not retrieve value " + this . getClass ( ) . getName ( ) ) ; return null ; } return futureValue . exceptionally ( t -> { logger . e...
Creates the JSON serialized form of the accessory for use over the Homekit Accessory Protocol .
151,179
protected void setJsonValue ( JsonObjectBuilder builder , T value ) { if ( value instanceof Boolean ) { builder . add ( "value" , ( Boolean ) value ) ; } else if ( value instanceof Double ) { builder . add ( "value" , ( Double ) value ) ; } else if ( value instanceof Integer ) { builder . add ( "value" , ( Integer ) va...
Writes the value key to the serialized characteristic
151,180
public void removeAll ( ) { LOGGER . debug ( "Removing {} reverse connections from subscription manager" , reverse . size ( ) ) ; Iterator < HomekitClientConnection > i = reverse . keySet ( ) . iterator ( ) ; while ( i . hasNext ( ) ) { HomekitClientConnection connection = i . next ( ) ; LOGGER . debug ( "Removing conn...
Remove all existing subscriptions
151,181
public void addAccessory ( HomekitAccessory accessory ) { if ( accessory . getId ( ) <= 1 && ! ( accessory instanceof Bridge ) ) { throw new IndexOutOfBoundsException ( "The ID of an accessory used in a bridge must be greater than 1" ) ; } addAccessorySkipRangeCheck ( accessory ) ; }
Add an accessory to be handled and advertised by this root . Any existing Homekit connections will be terminated to allow the clients to reconnect and see the updated accessory list . When using this for a bridge the ID of the accessory must be greater than 1 as that ID is reserved for the Bridge itself .
151,182
public void removeAccessory ( HomekitAccessory accessory ) { this . registry . remove ( accessory ) ; logger . info ( "Removed accessory " + accessory . getLabel ( ) ) ; if ( started ) { registry . reset ( ) ; webHandler . resetConnections ( ) ; } }
Removes an accessory from being handled or advertised by this root . Any existing Homekit connections will be terminated to allow the clients to reconnect and see the updated accessory list .
151,183
public int add ( DownloadRequest request ) throws IllegalArgumentException { checkReleased ( "add(...) called on a released ThinDownloadManager." ) ; if ( request == null ) { throw new IllegalArgumentException ( "DownloadRequest cannot be null" ) ; } return mRequestQueue . add ( request ) ; }
Add a new download . The download will start automatically once the download manager is ready to execute it and connectivity is available .
151,184
public DownloadRequest addCustomHeader ( String key , String value ) { mCustomHeader . put ( key , value ) ; return this ; }
Adds custom header to request
151,185
private void cleanupDestination ( DownloadRequest request , boolean forceClean ) { if ( ! request . isResumable ( ) || forceClean ) { Log . d ( "cleanupDestination() deleting " + request . getDestinationURI ( ) . getPath ( ) ) ; File destinationFile = new File ( request . getDestinationURI ( ) . getPath ( ) ) ; if ( de...
Called just before the thread finishes regardless of status to take any necessary action on the downloaded file with mDownloadedCacheSize file .
151,186
int add ( DownloadRequest request ) { int downloadId = getDownloadId ( ) ; request . setDownloadRequestQueue ( this ) ; synchronized ( mCurrentRequests ) { mCurrentRequests . add ( request ) ; } request . setDownloadId ( downloadId ) ; mDownloadQueue . add ( request ) ; return downloadId ; }
Generates a download id for the request and adds the download request to the download request queue for the dispatchers pool to act on immediately .
151,187
int query ( int downloadId ) { synchronized ( mCurrentRequests ) { for ( DownloadRequest request : mCurrentRequests ) { if ( request . getDownloadId ( ) == downloadId ) { return request . getDownloadState ( ) ; } } } return DownloadManager . STATUS_NOT_FOUND ; }
Returns the current download state for a download request .
151,188
int cancel ( int downloadId ) { synchronized ( mCurrentRequests ) { for ( DownloadRequest request : mCurrentRequests ) { if ( request . getDownloadId ( ) == downloadId ) { request . cancel ( ) ; return 1 ; } } } return 0 ; }
Cancel a particular download in progress . Returns 1 if the download Id is found else returns 0 .
151,189
void release ( ) { if ( mCurrentRequests != null ) { synchronized ( mCurrentRequests ) { mCurrentRequests . clear ( ) ; mCurrentRequests = null ; } } if ( mDownloadQueue != null ) { mDownloadQueue = null ; } if ( mDownloadDispatchers != null ) { stop ( ) ; for ( int i = 0 ; i < mDownloadDispatchers . length ; i ++ ) { ...
Cancels all the pending & running requests and releases all the dispatchers .
151,190
private void initialize ( Handler callbackHandler ) { int processors = Runtime . getRuntime ( ) . availableProcessors ( ) ; mDownloadDispatchers = new DownloadDispatcher [ processors ] ; mDelivery = new CallBackDelivery ( callbackHandler ) ; }
Perform construction .
151,191
private void initialize ( Handler callbackHandler , int threadPoolSize ) { mDownloadDispatchers = new DownloadDispatcher [ threadPoolSize ] ; mDelivery = new CallBackDelivery ( callbackHandler ) ; }
Perform construction with custom thread pool size .
151,192
private void stop ( ) { for ( int i = 0 ; i < mDownloadDispatchers . length ; i ++ ) { if ( mDownloadDispatchers [ i ] != null ) { mDownloadDispatchers [ i ] . quit ( ) ; } } }
Stops download dispatchers .
151,193
@ SuppressWarnings ( "unchecked" ) public Map < String , Field > getValueAsMap ( ) { return ( Map < String , Field > ) type . convert ( getValue ( ) , Type . MAP ) ; }
Returns the Map value of the field .
151,194
@ SuppressWarnings ( "unchecked" ) public List < Field > getValueAsList ( ) { return ( List < Field > ) type . convert ( getValue ( ) , Type . LIST ) ; }
Returns the List value of the field .
151,195
@ SuppressWarnings ( "unchecked" ) public LinkedHashMap < String , Field > getValueAsListMap ( ) { return ( LinkedHashMap < String , Field > ) type . convert ( getValue ( ) , Type . LIST_MAP ) ; }
Returns the ordered Map value of the field .
151,196
public Set < String > getAttributeNames ( ) { if ( attributes == null ) { return Collections . emptySet ( ) ; } else { return Collections . unmodifiableSet ( attributes . keySet ( ) ) ; } }
Returns the list of user defined attribute names .
151,197
public Map < String , String > getAttributes ( ) { if ( attributes == null ) { return null ; } else { return Collections . unmodifiableMap ( attributes ) ; } }
Get all field attributes in an unmodifiable Map or null if no attributes have been added
151,198
public static Object formatL ( final String template , final Object ... args ) { return new Object ( ) { public String toString ( ) { return format ( template , args ) ; } } ; }
format with lazy - eval
151,199
public List < ConfigIssue > init ( Service . Context context ) { this . context = context ; return init ( ) ; }
Initializes the service .