idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
27,400
public String convertToPrefixLength ( ) throws AddressStringException { IPAddress address = toAddress ( ) ; Integer prefix ; if ( address == null ) { if ( isPrefixOnly ( ) ) { prefix = getNetworkPrefixLength ( ) ; } else { return null ; } } else { prefix = address . getBlockMaskPrefixLength ( true ) ; if ( prefix == nu...
Converts this address to a prefix length
27,401
public int getTrailingBitCount ( boolean network ) { int count = getDivisionCount ( ) ; if ( count == 0 ) { return 0 ; } long back = network ? 0 : getDivision ( 0 ) . getMaxValue ( ) ; int bitLen = 0 ; for ( int i = count - 1 ; i >= 0 ; i -- ) { IPAddressDivision seg = getDivision ( i ) ; long value = seg . getDivision...
Returns the number of consecutive trailing one or zero bits . If network is true returns the number of consecutive trailing zero bits . Otherwise returns the number of consecutive trailing one bits .
27,402
public int getLeadingBitCount ( boolean network ) { int count = getDivisionCount ( ) ; if ( count == 0 ) { return 0 ; } long front = network ? getDivision ( 0 ) . getMaxValue ( ) : 0 ; int prefixLen = 0 ; for ( int i = 0 ; i < count ; i ++ ) { IPAddressDivision seg = getDivision ( i ) ; long value = seg . getDivisionVa...
Returns the number of consecutive leading one or zero bits . If network is true returns the number of consecutive leading one bits . Otherwise returns the number of consecutive leading zero bits .
27,403
public boolean isPrefixBlock ( ) { Integer networkPrefixLength = getNetworkPrefixLength ( ) ; if ( networkPrefixLength == null ) { return false ; } if ( getNetwork ( ) . getPrefixConfiguration ( ) . allPrefixedAddressesAreSubnets ( ) ) { return true ; } return containsPrefixBlock ( networkPrefixLength ) ; }
Returns whether this address section represents a subnet block of addresses associated its prefix length .
27,404
public boolean isSinglePrefixBlock ( ) { Integer networkPrefixLength = getNetworkPrefixLength ( ) ; if ( networkPrefixLength == null ) { return false ; } return containsSinglePrefixBlock ( networkPrefixLength ) ; }
Returns whether the division grouping range matches the block of values for its prefix length . In other words returns true if and only if it has a prefix length and it has just a single prefix .
27,405
public IPv6Address getIPv6Address ( IPv6AddressSegment segs [ ] ) { IPv6AddressCreator creator = getIPv6Network ( ) . getAddressCreator ( ) ; return creator . createAddress ( IPv6AddressSection . createSection ( creator , segs , this ) ) ; }
Create an IPv6 mixed address using the given ipv6 segments and using this address for the embedded IPv4 segments
27,406
public boolean isPrivate ( ) { IPv4AddressSegment seg0 = getSegment ( 0 ) ; IPv4AddressSegment seg1 = getSegment ( 1 ) ; return seg0 . matches ( 10 ) || seg0 . matches ( 172 ) && seg1 . matchesWithPrefixMask ( 16 , 4 ) || seg0 . matches ( 192 ) && seg1 . matches ( 168 ) ; }
Unicast addresses allocated for private use
27,407
public SpinJsonDataFormatException unableToParseValue ( String expectedType , JsonNodeType type ) { return new SpinJsonDataFormatException ( exceptionMessage ( "002" , "Expected '{}', got '{}'" , expectedType , type . toString ( ) ) ) ; }
Exception handler if we are unable to parse a json value into a java representation
27,408
protected void adoptElement ( DomXmlElement elementToAdopt ) { Document document = this . domElement . getOwnerDocument ( ) ; Element element = elementToAdopt . domElement ; if ( ! document . equals ( element . getOwnerDocument ( ) ) ) { Node node = document . adoptNode ( element ) ; if ( node == null ) { throw LOG . u...
Adopts an xml dom element to the owner document of this element if necessary .
27,409
public static void ensureChildElement ( DomXmlElement parentElement , DomXmlElement childElement ) { Node parent = childElement . unwrap ( ) . getParentNode ( ) ; if ( parent == null || ! parentElement . unwrap ( ) . isEqualNode ( parent ) ) { throw LOG . elementIsNotChildOfThisElement ( childElement , parentElement ) ...
Ensures that the element is child element of the parent element .
27,410
public static void ensureXPathNotNull ( Node node , String expression ) { if ( node == null ) { throw LOG . unableToFindXPathExpression ( expression ) ; } }
Ensure that the node is not null .
27,411
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 .
27,412
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 .
27,413
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 .
27,414
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
27,415
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 .
27,416
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
27,417
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
27,418
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 .
27,419
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 .
27,420
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 .
27,421
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 .
27,422
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 .
27,423
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 .
27,424
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 .
27,425
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 .
27,426
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 .
27,427
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 .
27,428
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 .
27,429
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 .
27,430
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 .
27,431
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 .
27,432
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
27,433
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 .
27,434
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 .
27,435
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 .
27,436
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
27,437
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 .
27,438
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 .
27,439
public static Filter . Builder makeAncestorFilter ( Key ancestor ) { return makeFilter ( DatastoreHelper . KEY_PROPERTY_NAME , PropertyFilter . Operator . HAS_ANCESTOR , makeValue ( ancestor ) ) ; }
Makes an ancestor filter .
27,440
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 .
27,441
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 .
27,442
public static Value . Builder makeValue ( Date date ) { return Value . newBuilder ( ) . setTimestampValue ( toTimestamp ( date . getTime ( ) * 1000L ) ) ; }
Make a timestamp value given a date .
27,443
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 .
27,444
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 .
27,445
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 .
27,446
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 .
27,447
@ 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 .
27,448
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 .
27,449
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 .
27,450
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 .
27,451
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...
27,452
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 .
27,453
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 .
27,454
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 .
27,455
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 .
27,456
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 .
27,457
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 .
27,458
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 .
27,459
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 .
27,460
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 .
27,461
@ 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 .
27,462
@ 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 .
27,463
@ 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 .
27,464
@ 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 .
27,465
@ 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 .
27,466
@ 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 .
27,467
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 .
27,468
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 .
27,469
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 .
27,470
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 .
27,471
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 .
27,472
@ 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 .
27,473
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 .
27,474
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 .
27,475
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 .
27,476
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 .
27,477
public static < T > Iterable < T > filterNull ( Iterable < T > unfiltered ) { return Iterables . filter ( unfiltered , Predicates . notNull ( ) ) ; }
Returns a new iterable filtering any null references .
27,478
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 .
27,479
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 .
27,480
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 .
27,481
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 .
27,482
@ 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
27,483
@ 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 .
27,484
public static < T > Iterator < T > filterNull ( Iterator < T > unfiltered ) { return Iterators . filter ( unfiltered , Predicates . notNull ( ) ) ; }
Returns a new iterator filtering any null references .
27,485
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 .
27,486
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 .
27,487
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 .
27,488
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 .
27,489
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
27,490
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
27,491
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 .
27,492
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 .
27,493
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 .
27,494
public DownloadRequest addCustomHeader ( String key , String value ) { mCustomHeader . put ( key , value ) ; return this ; }
Adds custom header to request
27,495
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 .
27,496
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 .
27,497
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 .
27,498
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 .
27,499
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 .