idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
22,400
public static void remove ( ServiceController < ? > controller ) { try { transition ( controller , State . REMOVED ) ; } catch ( StartException e ) { throw new IllegalStateException ( e ) ; } }
Ensures the specified service is removed .
22,401
public void run ( ) { long currentTimestamp = timeService . time ( ) ; for ( Map . Entry < CacheXid , TxState > entry : storage . entrySet ( ) ) { TxState state = entry . getValue ( ) ; CacheXid cacheXid = entry . getKey ( ) ; if ( ! state . hasTimedOut ( currentTimestamp ) || skipReaper ( state . getOriginator ( ) , c...
periodically checks for idle transactions and rollbacks them .
22,402
public ConfigurationBuilderHolder parseFile ( String filename , String transportOverrideResource , ServiceManager serviceManager ) throws IOException { ClassLoaderService classLoaderService = serviceManager . requestService ( ClassLoaderService . class ) ; try { return parseFile ( classLoaderService , filename , transp...
Resolves an Infinispan configuration file but using the Hibernate Search classloader . The returned Infinispan configuration template also overrides Infinispan s runtime classloader to the one of Hibernate Search .
22,403
private void patchTransportConfiguration ( ConfigurationBuilderHolder builderHolder , String transportOverrideResource ) throws IOException { if ( transportOverrideResource != null ) { try ( InputStream xml = FileLookupFactory . newInstance ( ) . lookupFileStrict ( transportOverrideResource , ispnClassLoadr ) ) { Prope...
After having parsed the Infinispan configuration file we might want to override the specified JGroups configuration file .
22,404
public Object performOnLostData ( ) { return StatsEnvelope . create ( f . apply ( EntryViews . noValue ( ( K ) key , keyDataConversion ) ) , true ) ; }
Apply function on entry without any data
22,405
public void start ( ) { endpointRouters . forEach ( r -> r . start ( routerConfiguration . getRoutingTable ( ) ) ) ; logger . printOutRoutingTable ( routerConfiguration . getRoutingTable ( ) ) ; }
Starts the router .
22,406
static Class < ? > getOutputType ( Class < ? > fieldType ) { if ( ! Number . class . isAssignableFrom ( fieldType ) ) { throw new IllegalStateException ( "Aggregation SUM cannot be applied to property of type " + fieldType . getName ( ) ) ; } if ( fieldType == Double . class || fieldType == Float . class ) { return Dou...
Determine the output type of this accumulator .
22,407
private void checkInterceptor ( Class < ? extends AsyncInterceptor > clazz ) { if ( containsInterceptorType ( clazz , false ) ) throw new CacheConfigurationException ( "Detected interceptor of type [" + clazz . getName ( ) + "] being added to the interceptor chain " + System . identityHashCode ( this ) + " more than on...
Ensures that the interceptor of type passed in isn t already added
22,408
public void accept ( Supplier < PrimitiveIterator . OfInt > segments ) { Supplier < PrimitiveIterator . OfInt > notifyThese ; Object key = currentKey . get ( ) ; if ( key != null ) { pendingSegments . put ( key , segments ) ; if ( currentKey . getAndSet ( null ) == null ) { notifyThese = pendingSegments . remove ( key ...
Method to be invoked after all entries have been passed to the stream that belong to these segments
22,409
public void valueIterated ( Object key ) { if ( ! currentKey . compareAndSet ( key , null ) ) { Supplier < PrimitiveIterator . OfInt > segments = pendingSegments . remove ( key ) ; if ( segments != null ) { completionListener . accept ( segments ) ; } } }
This method is to be invoked on possibly a different thread at any point which states that a key has been iterated upon . This is the signal that if a set of segments is waiting for a key to be iterated upon to notify the iteration
22,410
public SingletonStoreConfigurationBuilder < S > pushStateTimeout ( long l , TimeUnit unit ) { return pushStateTimeout ( unit . toMillis ( l ) ) ; }
If pushStateWhenCoordinator is true this property sets the maximum number of milliseconds that the process of pushing the in - memory state to the underlying cache loader should take .
22,411
private void forwardCommandRemotely ( RemoteTransaction remoteTx ) { Set < Object > affectedKeys = remoteTx . getAffectedKeys ( ) ; if ( trace ) log . tracef ( "Invoking forward of TxCompletionNotification for transaction %s. Affected keys: %s" , gtx , toStr ( affectedKeys ) ) ; stateTransferManager . forwardCommandIfN...
This only happens during state transfer .
22,412
public static Metadata applyVersion ( Metadata source , Metadata target ) { if ( target . version ( ) == null && source . version ( ) != null ) return target . builder ( ) . version ( source . version ( ) ) . build ( ) ; return target ; }
Applies version in source metadata to target metadata if no version in target metadata . This method can be useful in scenarios where source version information must be kept around i . e . write skew or when reading metadata from cache store .
22,413
public DeadlockDetectionConfigurationBuilder spinDuration ( long l , TimeUnit unit ) { return spinDuration ( unit . toMillis ( l ) ) ; }
Time period that determines how often is lock acquisition attempted within maximum time allowed to acquire a particular lock
22,414
private void forceExternalizerRegistration ( ConfigurationBuilderHolder configurationBuilderHolder ) { SerializationConfigurationBuilder serialization = configurationBuilderHolder . getGlobalConfigurationBuilder ( ) . serialization ( ) ; LifecycleCallbacks . moduleExternalizers ( ) . forEach ( ( i , e ) -> serializatio...
Do not rely on automatic discovery but enforce the registration of the required Externalizers .
22,415
public static boolean isVersionPre12 ( Configuration cfg ) { String version = cfg . version ( ) . toString ( ) ; return Objects . equals ( version , "1.0" ) || Objects . equals ( version , "1.1" ) ; }
Is version previous to and not including 1 . 2?
22,416
public synchronized TransactionManager getTransactionManager ( ) { if ( ! lookupDone ) { doLookups ( globalCfg . classLoader ( ) ) ; } if ( tm != null ) return tm ; if ( lookupFailed ) { if ( ! noJBossTM ) { tryEmbeddedJBossTM ( ) ; } if ( noJBossTM ) { useDummyTM ( ) ; } } return tm ; }
Get the system - wide used TransactionManager
22,417
private void doLookups ( ClassLoader cl ) { if ( lookupFailed ) return ; InitialContext ctx ; try { ctx = new InitialContext ( ) ; } catch ( NamingException e ) { log . failedToCreateInitialCtx ( e ) ; lookupFailed = true ; return ; } try { for ( LookupNames . JndiTransactionManager knownJNDIManager : LookupNames . Jnd...
Try to figure out which TransactionManager to use
22,418
public void registerPersisterSpace ( String entityName , Tree aliasTree ) { String aliasText = aliasTree . getText ( ) ; String previous = aliasToEntityType . put ( aliasText , entityName ) ; if ( previous != null && ! previous . equalsIgnoreCase ( entityName ) ) { throw new UnsupportedOperationException ( "Alias reuse...
See rule entityName
22,419
public void setPropertyPath ( PropertyPath < TypeDescriptor < TypeMetadata > > propertyPath ) { if ( aggregationFunction != null ) { if ( propertyPath == null && aggregationFunction != AggregationFunction . COUNT && aggregationFunction != AggregationFunction . COUNT_DISTINCT ) { throw log . getAggregationCanOnlyBeAppli...
Sets a property path representing one property in the SELECT GROUP BY WHERE or HAVING clause of a given query .
22,420
public void sortSpecification ( String collateName , boolean isAscending ) { PropertyPath < TypeDescriptor < TypeMetadata > > property = resolveAlias ( propertyPath ) ; checkAnalyzed ( property , false ) ; if ( sortFields == null ) { sortFields = new ArrayList < > ( ARRAY_INITIAL_LENGTH ) ; } sortFields . add ( new Ick...
Add field sort criteria .
22,421
public void groupingValue ( String collateName ) { if ( groupBy == null ) { groupBy = new ArrayList < > ( ARRAY_INITIAL_LENGTH ) ; } groupBy . add ( resolveAlias ( propertyPath ) ) ; }
Add group by criteria .
22,422
private Map < Address , IntSet > backupOwnersOfSegments ( ConsistentHash ch , IntSet segments ) { Map < Address , IntSet > map = new HashMap < > ( ch . getMembers ( ) . size ( ) ) ; if ( ch . isReplicated ( ) ) { for ( Address member : ch . getMembers ( ) ) { map . put ( member , segments ) ; } map . remove ( rpcManage...
we re assuming that this function is ran on primary owner of given segments
22,423
private boolean allIdentity ( Class < ? extends Encoder > keyEncoderClass , Class < ? extends Encoder > valueEncoderClass , Class < ? extends Wrapper > keyWrapperClass , Class < ? extends Wrapper > valueWrapperClass ) { return keyEncoderClass == IdentityEncoder . class && valueEncoderClass == IdentityEncoder . class &&...
If encoders and wrappers are all identity we should just return the normal cache and avoid all wrappings
22,424
public void cancelQueuedTasks ( ) { ArrayList < QueueingTask > queuedTasks = new ArrayList < QueueingTask > ( ) ; queue . drainTo ( queuedTasks ) ; for ( QueueingTask task : queuedTasks ) { task . cancel ( false ) ; } }
When stopping cancel any queued tasks .
22,425
protected void recoverServices ( OperationContext context , ModelNode operation , ModelNode model ) throws OperationFailedException { PathAddress address = context . getCurrentAddress ( ) ; CacheContainerAddHandler . installRuntimeServices ( context , operation , model ) ; for ( CacheType type : CacheType . values ( ) ...
Method to re - install any services associated with existing local caches .
22,426
public static final int parseInt ( String value , int defValue , String errorMsgOnParseFailure ) { if ( StringHelper . isEmpty ( value ) ) { return defValue ; } else { return parseInt ( value , errorMsgOnParseFailure ) ; } }
In case value is null or an empty string the defValue is returned
22,427
public static int parseInt ( String value , String errorMsgOnParseFailure ) { if ( value == null ) { throw new SearchException ( errorMsgOnParseFailure ) ; } else { try { return Integer . parseInt ( value . trim ( ) ) ; } catch ( NumberFormatException nfe ) { throw log . getInvalidIntegerValueException ( errorMsgOnPars...
Parses a string into an integer value .
22,428
public static final boolean getBooleanValue ( Properties cfg , String key , boolean defaultValue ) { String propValue = cfg . getProperty ( key ) ; if ( propValue == null ) { return defaultValue ; } else { return parseBoolean ( propValue , "Property '" + key + "' needs to be either literal 'true' or 'false'" ) ; } }
Extracts a boolean value from configuration properties
22,429
public static final boolean parseBoolean ( String value , String errorMsgOnParseFailure ) { if ( value == null ) { throw new SearchException ( errorMsgOnParseFailure ) ; } else if ( "false" . equalsIgnoreCase ( value . trim ( ) ) ) { return false ; } else if ( "true" . equalsIgnoreCase ( value . trim ( ) ) ) { return t...
Parses a string to recognize exactly either true or false .
22,430
public static final String getString ( Properties cfg , String key , String defaultValue ) { if ( cfg == null ) { return defaultValue ; } else { String propValue = cfg . getProperty ( key ) ; return propValue == null ? defaultValue : propValue ; } }
Get the string property or defaults if not present
22,431
public GlobalJmxStatisticsConfigurationBuilder withProperties ( Properties properties ) { attributes . attribute ( PROPERTIES ) . set ( new TypedProperties ( properties ) ) ; return this ; }
Sets properties which are then passed to the MBean Server Lookup implementation specified .
22,432
public void serialize ( OutputStream os , String name , Configuration configuration ) throws XMLStreamException { serialize ( os , null , Collections . singletonMap ( name , configuration ) ) ; }
Serializes a single configuration to an OutputStream
22,433
public String serialize ( String name , Configuration configuration ) { try { ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; serialize ( os , name , configuration ) ; return os . toString ( "UTF-8" ) ; } catch ( Exception e ) { throw new CacheConfigurationException ( e ) ; } }
Serializes a single configuration to a String
22,434
public static RetryOnFailureXSiteCommand newInstance ( XSiteBackup backup , XSiteReplicateCommand command , RetryPolicy retryPolicy ) { assertNotNull ( backup , "XSiteBackup" ) ; assertNotNull ( command , "XSiteReplicateCommand" ) ; assertNotNull ( retryPolicy , "RetryPolicy" ) ; return new RetryOnFailureXSiteCommand (...
It builds a new instance with the destination site the command and the retry policy .
22,435
public CacheTopology computePreferredTopology ( Map < Address , CacheStatusResponse > statusResponseMap ) { List < Partition > partitions = computePartitions ( statusResponseMap , "" ) ; return partitions . size ( ) != 0 ? selectPreferredPartition ( partitions ) . topology : null ; }
Ignore the AvailabilityStrategyContext and only compute the preferred topology for testing .
22,436
public ConsistentHash getReadConsistentHash ( ) { switch ( phase ) { case CONFLICT_RESOLUTION : case NO_REBALANCE : assert pendingCH == null ; assert unionCH == null ; return currentCH ; case TRANSITORY : return pendingCH ; case READ_OLD_WRITE_ALL : assert pendingCH != null ; assert unionCH != null ; return currentCH ;...
Read operations should always go to the current owners .
22,437
public OutputStream getOutput ( String pathname , boolean append ) throws IOException { return getOutput ( pathname , append , defaultChunkSize ) ; }
Opens an OutputStream for writing to the file denoted by pathname . The OutputStream can either overwrite the existing file or append to it .
22,438
public OutputStream getOutput ( String pathname , boolean append , int chunkSize ) throws IOException { GridFile file = ( GridFile ) getFile ( pathname , chunkSize ) ; checkIsNotDirectory ( file ) ; createIfNeeded ( file ) ; return new GridOutputStream ( file , append , data ) ; }
Opens an OutputStream for writing to the file denoted by pathname .
22,439
public OutputStream getOutput ( GridFile file ) throws IOException { checkIsNotDirectory ( file ) ; createIfNeeded ( file ) ; return new GridOutputStream ( file , false , data ) ; }
Opens an OutputStream for writing to the given file .
22,440
public InputStream getInput ( String pathname ) throws FileNotFoundException { GridFile file = ( GridFile ) getFile ( pathname ) ; checkFileIsReadable ( file ) ; return new GridInputStream ( file , data ) ; }
Opens an InputStream for reading from the file denoted by pathname .
22,441
public InputStream getInput ( File file ) throws FileNotFoundException { return file != null ? getInput ( file . getPath ( ) ) : null ; }
Opens an InputStream for reading from the given file .
22,442
public WritableGridFileChannel getWritableChannel ( String pathname , boolean append ) throws IOException { return getWritableChannel ( pathname , append , defaultChunkSize ) ; }
Opens a WritableGridFileChannel for writing to the file denoted by pathname . The channel can either overwrite the existing file or append to it .
22,443
public WritableGridFileChannel getWritableChannel ( String pathname , boolean append , int chunkSize ) throws IOException { GridFile file = ( GridFile ) getFile ( pathname , chunkSize ) ; checkIsNotDirectory ( file ) ; createIfNeeded ( file ) ; return new WritableGridFileChannel ( file , data , append ) ; }
Opens a WritableGridFileChannel for writing to the file denoted by pathname .
22,444
void remove ( String absolutePath ) { if ( absolutePath == null ) return ; GridFile . Metadata md = metadata . get ( absolutePath ) ; if ( md == null ) return ; int numChunks = md . getLength ( ) / md . getChunkSize ( ) + 1 ; for ( int i = 0 ; i < numChunks ; i ++ ) data . remove ( FileChunkMapper . getChunkKey ( absol...
Removes the file denoted by absolutePath .
22,445
public AdvancedExternalizer get ( Class key ) { final Class [ ] keys = this . keys ; final int mask = keys . length - 1 ; int hc = System . identityHashCode ( key ) & mask ; Class k ; for ( ; ; ) { k = keys [ hc ] ; if ( k == key ) { return values [ hc ] ; } if ( k == null ) { return null ; } hc = ( hc + 1 ) & mask ; }...
Get a value from the map .
22,446
public void put ( Class key , AdvancedExternalizer value ) { final Class [ ] keys = this . keys ; final int mask = keys . length - 1 ; final AdvancedExternalizer [ ] values = this . values ; Class k ; int hc = System . identityHashCode ( key ) & mask ; for ( int idx = hc ; ; idx = hc ++ & mask ) { k = keys [ idx ] ; if...
Put a value into the map . Any previous mapping is discarded silently .
22,447
public void execute ( OperationContext context , ModelNode operation ) throws OperationFailedException { nameValidator . validate ( operation ) ; final String attributeName = operation . require ( NAME ) . asString ( ) ; final ModelNode submodel = context . readResource ( PathAddress . EMPTY_ADDRESS ) . getModel ( ) ; ...
A read handler which performs special processing for MODE attributes
22,448
@ SuppressWarnings ( "unchecked" ) private static < T > T [ ] finishToArray ( T [ ] r , Iterator < ? > it ) { int i = r . length ; while ( it . hasNext ( ) ) { int cap = r . length ; if ( i == cap ) { int newCap = cap + ( cap >> 1 ) + 1 ; if ( newCap - MAX_ARRAY_SIZE > 0 ) newCap = hugeCapacity ( cap + 1 ) ; r = Arrays...
Copied from AbstractCollection to support toArray methods
22,449
public StoreAsBinaryConfigurationBuilder enable ( ) { attributes . attribute ( ENABLED ) . set ( true ) ; getBuilder ( ) . memory ( ) . storageType ( StorageType . BINARY ) ; return this ; }
Enables storing both keys and values as binary .
22,450
public StoreAsBinaryConfigurationBuilder disable ( ) { attributes . attribute ( ENABLED ) . set ( false ) ; getBuilder ( ) . memory ( ) . storageType ( StorageType . OBJECT ) ; return this ; }
Disables storing both keys and values as binary .
22,451
public StoreAsBinaryConfigurationBuilder enabled ( boolean enabled ) { attributes . attribute ( ENABLED ) . set ( enabled ) ; getBuilder ( ) . memory ( ) . storageType ( enabled ? StorageType . BINARY : StorageType . OBJECT ) ; return this ; }
Sets whether this feature is enabled or disabled .
22,452
public boolean remove ( String fileName ) { writeLock . lock ( ) ; try { return filenames . remove ( fileName ) ; } finally { writeLock . unlock ( ) ; } }
Removes the filename from the set if it exists
22,453
public boolean add ( String fileName ) { writeLock . lock ( ) ; try { return filenames . add ( fileName ) ; } finally { writeLock . unlock ( ) ; } }
Adds the filename from the set if it exists
22,454
public void forEach ( LongConsumer action ) { if ( ! rehashAware ) { performOperation ( TerminalFunctions . forEachFunction ( action ) , false , ( v1 , v2 ) -> null , null ) ; } else { performRehashKeyTrackingOperation ( s -> getForEach ( action , s ) ) ; } }
Reset are terminal operators
22,455
public List < T > topologicalSort ( ) throws CyclicDependencyException { lock . readLock ( ) . lock ( ) ; try { ArrayList < T > result = new ArrayList < > ( ) ; Deque < T > noIncomingEdges = new ArrayDeque < > ( ) ; Map < T , Integer > temp = new HashMap < > ( ) ; for ( Map . Entry < T , Set < T > > incoming : incoming...
Calculates a topological sort of the graph in linear time
22,456
public void addDependency ( T from , T to ) { if ( from == null || to == null || from . equals ( to ) ) { throw new IllegalArgumentException ( "Invalid parameters" ) ; } lock . writeLock ( ) . lock ( ) ; try { if ( addOutgoingEdge ( from , to ) ) { addIncomingEdge ( to , from ) ; } } finally { lock . writeLock ( ) . un...
Add a dependency between two elements
22,457
public void removeDependency ( T from , T to ) { lock . writeLock ( ) . lock ( ) ; try { Set < T > dependencies = outgoingEdges . get ( from ) ; if ( dependencies == null || ! dependencies . contains ( to ) ) { throw new IllegalArgumentException ( "Inexistent dependency" ) ; } dependencies . remove ( to ) ; incomingEdg...
Remove a dependency
22,458
public boolean hasDependent ( T element ) { lock . readLock ( ) . lock ( ) ; try { Set < T > ts = this . incomingEdges . get ( element ) ; return ts != null && ts . size ( ) > 0 ; } finally { lock . readLock ( ) . unlock ( ) ; } }
Check if an element is depended on
22,459
public Set < T > getDependents ( T element ) { lock . readLock ( ) . lock ( ) ; try { Set < T > dependants = this . incomingEdges . get ( element ) ; if ( dependants == null || dependants . isEmpty ( ) ) { return new HashSet < > ( ) ; } return Collections . unmodifiableSet ( this . incomingEdges . get ( element ) ) ; }...
Return the dependents
22,460
public void remove ( T element ) { lock . writeLock ( ) . lock ( ) ; try { if ( outgoingEdges . remove ( element ) != null ) { for ( Set < T > values : outgoingEdges . values ( ) ) { values . remove ( element ) ; } } if ( incomingEdges . remove ( element ) != null ) { for ( Set < T > values : incomingEdges . values ( )...
Remove element from the graph
22,461
private void clearHeader ( ) { if ( mHeader != null ) { removeView ( mHeader ) ; mHeader = null ; mHeaderId = null ; mHeaderPosition = null ; mHeaderOffset = null ; mList . setTopClippingLength ( 0 ) ; updateHeaderVisibilities ( ) ; } }
This is called in response to the data set or the adapter changing
22,462
private void updateHeaderVisibilities ( ) { int top = stickyHeaderTop ( ) ; int childCount = mList . getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { View child = mList . getChildAt ( i ) ; if ( ! ( child instanceof WrapperView ) ) { continue ; } WrapperView wrapperViewChild = ( WrapperView ) child ; if ...
Makes sure the other ones are showing
22,463
@ SuppressLint ( "NewApi" ) private void setHeaderOffet ( int offset ) { if ( mHeaderOffset == null || mHeaderOffset != offset ) { mHeaderOffset = offset ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB ) { mHeader . setTranslationY ( mHeaderOffset ) ; } else { MarginLayoutParams params = ( MarginL...
the API version
22,464
private void animateView ( final View target , final int type ) { if ( ANIMATION_EXPAND == type && target . getVisibility ( ) == VISIBLE ) { return ; } if ( ANIMATION_COLLAPSE == type && target . getVisibility ( ) != VISIBLE ) { return ; } if ( mDefaultAnimExecutor != null ) { mDefaultAnimExecutor . executeAnim ( targe...
Performs either COLLAPSE or EXPAND animation on the target view
22,465
public static DescribeCommand on ( String evaluateOnCommit , Repository repo , LoggerBridge log ) { return new DescribeCommand ( evaluateOnCommit , repo , log ) ; }
Creates a new describe command which interacts with a single repository
22,466
protected String stripCredentialsFromOriginUrl ( String gitRemoteString ) throws GitCommitIdExecutionException { if ( gitRemoteString == null ) { return gitRemoteString ; } if ( GIT_SCP_FORMAT . matcher ( gitRemoteString ) . matches ( ) ) { return gitRemoteString ; } try { URI original = new URI ( gitRemoteString ) ; S...
If the git remote value is a URI and contains a user info component strip the password from it if it exists .
22,467
private File findProjectGitDirectory ( ) { if ( this . mavenProject == null ) { return null ; } File basedir = mavenProject . getBasedir ( ) ; while ( basedir != null ) { File gitdir = new File ( basedir , Constants . DOT_GIT ) ; if ( gitdir . exists ( ) ) { if ( gitdir . isDirectory ( ) ) { return gitdir ; } else if (...
Search up all the maven parent project hierarchy until a . git directory is found .
22,468
public String toJson ( ) { StringBuilder sb = new StringBuilder ( "{" ) ; appendProperty ( sb , "branch" , branch ) ; appendProperty ( sb , "commitId" , commitId ) ; appendProperty ( sb , "commitIdAbbrev" , commitIdAbbrev ) ; appendProperty ( sb , "commitTime" , commitTime ) ; appendProperty ( sb , "commitUserName" , c...
If you need it as json but don t have jackson installed etc
22,469
private synchronized boolean markIsTransaction ( String channelId , String uuid , boolean isTransaction ) { if ( this . isTransaction == null ) { return false ; } String key = getTxKey ( channelId , uuid ) ; this . isTransaction . put ( key , isTransaction ) ; return true ; }
Marks a CHANNELID + UUID as either a transaction or a query
22,470
ByteString getState ( String channelId , String txId , String collection , String key ) { return invokeChaincodeSupport ( newGetStateEventMessage ( channelId , txId , collection , key ) ) ; }
handleGetState communicates with the validator to fetch the requested state information from the ledger .
22,471
private Response delete ( ChaincodeStub stub , List < String > args ) { if ( args . size ( ) != 1 ) { return newErrorResponse ( "Incorrect number of arguments. Expecting 1" ) ; } String key = args . get ( 0 ) ; stub . delState ( key ) ; return newSuccessResponse ( ) ; }
Deletes an entity from state
22,472
static SignaturePolicy nOutOf ( int n , List < SignaturePolicy > policies ) { return SignaturePolicy . newBuilder ( ) . setNOutOf ( NOutOf . newBuilder ( ) . setN ( n ) . addAllRules ( policies ) . build ( ) ) . build ( ) ; }
Creates a policy which requires N out of the slice of policies to evaluate to true
22,473
private Response query ( ChaincodeStub stub , List < String > args ) { if ( args . size ( ) != 1 ) { return newErrorResponse ( "Incorrect number of arguments. Expecting name of the person to query" ) ; } String key = args . get ( 0 ) ; String val = stub . getStringState ( key ) ; if ( val == null ) { return newErrorRes...
query callback representing the query of a chaincode
22,474
public Response init ( ChaincodeStub stub ) { try { List < String > args = stub . getParameters ( ) ; if ( args . size ( ) != 2 ) { newErrorResponse ( "Incorrect arguments. Expecting a key and a value" ) ; } stub . putStringState ( args . get ( 0 ) , args . get ( 1 ) ) ; return newSuccessResponse ( ) ; } catch ( Throwa...
Init is called during chaincode instantiation to initialize any data . Note that chaincode upgrade also calls this function to reset or to migrate data .
22,475
public Response invoke ( ChaincodeStub stub ) { try { String func = stub . getFunction ( ) ; List < String > params = stub . getParameters ( ) ; if ( func . equals ( "set" ) ) { return newSuccessResponse ( set ( stub , params ) ) ; } else if ( func . equals ( "get" ) ) { return newSuccessResponse ( get ( stub , params ...
Invoke is called per transaction on the chaincode . Each transaction is either a get or a set on the asset created by Init function . The Set method may create a new asset by specifying a new key - value pair .
22,476
private String get ( ChaincodeStub stub , List < String > args ) { if ( args . size ( ) != 1 ) { throw new RuntimeException ( "Incorrect arguments. Expecting a key" ) ; } String value = stub . getStringState ( args . get ( 0 ) ) ; if ( value == null || value . isEmpty ( ) ) { throw new RuntimeException ( "Asset not fou...
get returns the value of the specified asset key
22,477
public void addContent ( Content content ) { Content newContent = new Content ( ) ; newContent . setType ( content . getType ( ) ) ; newContent . setValue ( content . getValue ( ) ) ; this . content = addToList ( newContent , this . content ) ; }
Add content to this email .
22,478
public void addAttachments ( Attachments attachments ) { Attachments newAttachment = new Attachments ( ) ; newAttachment . setContent ( attachments . getContent ( ) ) ; newAttachment . setType ( attachments . getType ( ) ) ; newAttachment . setFilename ( attachments . getFilename ( ) ) ; newAttachment . setDisposition ...
Add attachments to the email .
22,479
public void addSection ( String key , String value ) { this . sections = addToMap ( key , value , this . sections ) ; }
Add a section to the email .
22,480
public void addHeader ( String key , String value ) { this . headers = addToMap ( key , value , this . headers ) ; }
Add a header to the email .
22,481
public void addCustomArg ( String key , String value ) { this . customArgs = addToMap ( key , value , this . customArgs ) ; }
Add a custom argument to the email .
22,482
public String buildPretty ( ) throws IOException { try { ObjectMapper mapper = new ObjectMapper ( ) ; return mapper . writerWithDefaultPrettyPrinter ( ) . writeValueAsString ( this ) ; } catch ( IOException ex ) { throw ex ; } }
Create a string represenation of the Mail object JSON and pretty print it .
22,483
public Map < String , String > addRequestHeader ( String key , String value ) { this . requestHeaders . put ( key , value ) ; return getRequestHeaders ( ) ; }
Add a new request header .
22,484
public Map < String , String > removeRequestHeader ( String key ) { this . requestHeaders . remove ( key ) ; return getRequestHeaders ( ) ; }
Remove a request header .
22,485
public Response api ( Request request ) throws IOException { Request req = new Request ( ) ; req . setMethod ( request . getMethod ( ) ) ; req . setBaseUri ( this . host ) ; req . setEndpoint ( "/" + version + "/" + request . getEndpoint ( ) ) ; req . setBody ( request . getBody ( ) ) ; for ( Map . Entry < String , Str...
Class api sets up the request to the SendGrid API this is main interface .
22,486
public void attempt ( Request request ) { this . attempt ( request , new APICallback ( ) { public void error ( Exception ex ) { } public void response ( Response r ) { } } ) ; }
Attempt an API call . This method executes the API call asynchronously on an internal thread pool . If the call is rate limited the thread will retry up to the maximum configured time .
22,487
public void attempt ( final Request request , final APICallback callback ) { this . pool . execute ( new Runnable ( ) { public void run ( ) { Response response ; for ( int i = 0 ; i < rateLimitRetry ; ++ i ) { try { response = api ( request ) ; } catch ( IOException ex ) { callback . error ( ex ) ; return ; } if ( resp...
Attempt an API call . This method executes the API call asynchronously on an internal thread pool . If the call is rate limited the thread will retry up to the maximum configured time . The supplied callback will be called in the event of an error or a successful response .
22,488
public static Mail buildDynamicTemplate ( ) throws IOException { Mail mail = new Mail ( ) ; Email fromEmail = new Email ( ) ; fromEmail . setName ( "Example User" ) ; fromEmail . setEmail ( "test@example.com" ) ; mail . setFrom ( fromEmail ) ; mail . setTemplateId ( "d-c6dcf1f72bdd4beeb15a9aa6c72fcd2c" ) ; Personalizat...
API V3 Dynamic Template implementation
22,489
public static Mail buildHelloEmail ( ) throws IOException { Email from = new Email ( "test@example.com" ) ; String subject = "Hello World from the SendGrid Java Library" ; Email to = new Email ( "test@example.com" ) ; Content content = new Content ( "text/plain" , "some text here" ) ; Mail mail = new Mail ( from , subj...
Minimum required to send an email
22,490
public SymbolOptions withLatLng ( LatLng latLng ) { geometry = Point . fromLngLat ( latLng . getLongitude ( ) , latLng . getLatitude ( ) ) ; return this ; }
Set the LatLng of the symbol which represents the location of the symbol on the map
22,491
public LatLng getLatLng ( ) { if ( geometry == null ) { return null ; } return new LatLng ( geometry . latitude ( ) , geometry . longitude ( ) ) ; }
Get the LatLng of the symbol which represents the location of the symbol on the map
22,492
public static void clearRecentHistory ( Context context ) { SearchHistoryDatabase database = SearchHistoryDatabase . getInstance ( context ) ; SearchHistoryDatabase . deleteAllData ( database ) ; }
If the search history is being displayed in the search results section you should provide a setting for the user to clear their search history . Calling this method will remove all entries from the database .
22,493
public T create ( S options ) { T t = options . build ( currentId , this ) ; annotations . put ( t . getId ( ) , t ) ; currentId ++ ; updateSource ( ) ; return t ; }
Create an annotation on the map
22,494
public List < T > create ( List < S > optionsList ) { List < T > annotationList = new ArrayList < > ( ) ; for ( S options : optionsList ) { T annotation = options . build ( currentId , this ) ; annotationList . add ( annotation ) ; annotations . put ( annotation . getId ( ) , annotation ) ; currentId ++ ; } updateSourc...
Create a list of annotations on the map .
22,495
public void delete ( List < T > annotationList ) { for ( T annotation : annotationList ) { annotations . remove ( annotation . getId ( ) ) ; } updateSource ( ) ; }
Deletes annotations from the map .
22,496
public void update ( T annotation ) { if ( annotations . containsValue ( annotation ) ) { annotations . put ( annotation . getId ( ) , annotation ) ; updateSource ( ) ; } else { Logger . e ( TAG , "Can't update annotation: " + annotation . toString ( ) + ", the annotation isn't active annotation." ) ; } }
Update an annotation on the map .
22,497
public void update ( List < T > annotationList ) { for ( T annotation : annotationList ) { annotations . put ( annotation . getId ( ) , annotation ) ; } updateSource ( ) ; }
Update annotations on the map .
22,498
public void onDestroy ( ) { mapboxMap . removeOnMapClickListener ( mapClickResolver ) ; mapboxMap . removeOnMapLongClickListener ( mapClickResolver ) ; dragListeners . clear ( ) ; clickListeners . clear ( ) ; longClickListeners . clear ( ) ; }
Cleanup annotation manager used to clear listeners
22,499
public static Builder builder ( ) { return new AutoValue_OfflineDownloadOptions . Builder ( ) . uuid ( UUID . randomUUID ( ) . getMostSignificantBits ( ) ) . metadata ( new byte [ ] { } ) . progress ( 0 ) ; }
Used to build a new instance of this class .