idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
18,300 | public A notificationType ( String type ) { this . headers . add ( Pair . of ( "X-WindowsPhone-Target" , type ) ) ; return ( A ) this ; } | Sets the type of the push notification being sent . |
18,301 | public A callbackUri ( String callbackUri ) { this . headers . add ( Pair . of ( "X-CallbackURI" , callbackUri ) ) ; return ( A ) this ; } | Sets the notification channel URI that the registered callback message will be sent to . |
18,302 | protected A contentType ( String contentType ) { this . headers . add ( Pair . of ( "Content-Type" , contentType ) ) ; return ( A ) this ; } | Sets the notification body content type |
18,303 | public static byte [ ] pBKDF2ObfuscatePassword ( String password , byte [ ] salt ) throws NoSuchAlgorithmException , InvalidKeySpecException { String algorithm = "PBKDF2WithHmacSHA1" ; int derivedKeyLength = 160 ; int iterations = 20000 ; KeySpec spec = new PBEKeySpec ( password . toCharArray ( ) , salt , iterations , derivedKeyLength ) ; SecretKeyFactory f = SecretKeyFactory . getInstance ( algorithm ) ; return f . generateSecret ( spec ) . getEncoded ( ) ; } | Encrypt the password in PBKDF2 algorithm . |
18,304 | public static byte [ ] computeHash ( String passwd ) throws NoSuchAlgorithmException { java . security . MessageDigest md = java . security . MessageDigest . getInstance ( "SHA-1" ) ; md . reset ( ) ; md . update ( passwd . getBytes ( ) ) ; return md . digest ( ) ; } | Compute the the hash value for the String . |
18,305 | public static byte [ ] generateSalt ( ) throws NoSuchAlgorithmException { SecureRandom random = SecureRandom . getInstance ( "SHA1PRNG" ) ; byte [ ] salt = new byte [ 8 ] ; random . nextBytes ( salt ) ; return salt ; } | Generate a random salt . |
18,306 | public Map < String , StatsMap > extractCollectingStatsMap ( List < Number > dataList ) { return JMMap . newChangedValueMap ( this , this :: buildStatsMap ) ; } | Extract collecting stats map map . |
18,307 | public void list ( final String aBucket , final Handler < HttpClientResponse > aHandler ) { createGetRequest ( aBucket , "?list-type=2" , aHandler ) . end ( ) ; } | Asynchronous listing of an S3 bucket . |
18,308 | public void put ( final String aBucket , final String aKey , final AsyncFile aFile , final Handler < HttpClientResponse > aHandler ) { final S3ClientRequest request = createPutRequest ( aBucket , aKey , aHandler ) ; final Buffer buffer = Buffer . buffer ( ) ; aFile . endHandler ( event -> { request . putHeader ( HttpHeaders . CONTENT_LENGTH , String . valueOf ( buffer . length ( ) ) ) ; request . end ( buffer ) ; } ) ; aFile . handler ( data -> { buffer . appendBuffer ( data ) ; } ) ; } | Uploads the file contents to S3 . |
18,309 | public String getErrorMessage ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( exceptionCode . getCode ( ) ) . append ( ":" ) . append ( exceptionCode . getMessage ( ) ) ; if ( this . message != null && ! this . message . isEmpty ( ) ) { sb . append ( " - " ) . append ( message ) ; } return sb . toString ( ) ; } | Get the locale - specific error message . |
18,310 | public static Bits divide ( long numerator , long denominator , long maxBits ) { if ( maxBits <= 0 ) return NULL ; if ( numerator == 0 ) return ZERO ; if ( numerator == denominator ) return ONE ; if ( numerator < denominator ) { return ZERO . concatenate ( divide ( numerator * 2 , denominator , maxBits - 1 ) ) ; } else { return ONE . concatenate ( divide ( 2 * ( numerator - denominator ) , denominator , maxBits - 1 ) ) ; } } | Divide bits . |
18,311 | public static int dataCompare ( final Bits left , final Bits right ) { for ( int i = 0 ; i < left . bytes . length ; i ++ ) { if ( right . bytes . length <= i ) { return 1 ; } final int a = left . bytes [ i ] & 0xFF ; final int b = right . bytes [ i ] & 0xFF ; if ( a < b ) { return - 1 ; } if ( a > b ) { return 1 ; } } if ( left . bitLength < right . bitLength ) { return - 1 ; } if ( left . bitLength > right . bitLength ) { return 1 ; } return 0 ; } | Data compare int . |
18,312 | public static byte highestOneBit ( final long v ) { final long h = Long . highestOneBit ( v ) ; if ( 0 == v ) { return 0 ; } for ( byte i = 0 ; i < 64 ; i ++ ) { if ( h == 1l << i ) { return ( byte ) ( i + 1 ) ; } } throw new RuntimeException ( ) ; } | Highest one bit byte . |
18,313 | public static void shiftLeft ( final byte [ ] src , final int bits , final byte [ ] dst ) { final int bitPart = bits % 8 ; final int bytePart = bits / 8 ; for ( int i = 0 ; i < dst . length ; i ++ ) { final int a = i + bytePart ; if ( a >= 0 && src . length > a ) { dst [ i ] |= ( byte ) ( ( src [ a ] & 0xFF ) << bitPart & 0xFF ) ; } final int b = i + bytePart + 1 ; if ( b >= 0 && src . length > b ) { dst [ i ] |= ( byte ) ( ( src [ b ] & 0xFF ) >> 8 - bitPart & 0xFF ) ; } } } | Shift left . |
18,314 | public Bits bitwiseXor ( final Bits right ) { final int lengthDifference = this . bitLength - right . bitLength ; if ( lengthDifference < 0 ) { return this . concatenate ( new Bits ( 0l , - lengthDifference ) ) . bitwiseXor ( right ) ; } if ( lengthDifference > 0 ) { return this . bitwiseXor ( right . concatenate ( new Bits ( 0l , lengthDifference ) ) ) ; } final Bits returnValue = new Bits ( new byte [ this . bytes . length ] , this . bitLength ) ; for ( int i = 0 ; i < this . bytes . length ; i ++ ) { returnValue . bytes [ i ] = this . bytes [ i ] ; } for ( int i = 0 ; i < right . bytes . length ; i ++ ) { returnValue . bytes [ i ] ^= right . bytes [ i ] ; } return returnValue ; } | Bitwise xor bits . |
18,315 | public Bits concatenate ( final Bits right ) { final int newBitLength = this . bitLength + right . bitLength ; final int newByteLength = ( int ) Math . ceil ( newBitLength / 8. ) ; final Bits result = new Bits ( new byte [ newByteLength ] , newBitLength ) ; shiftLeft ( this . bytes , 0 , result . bytes ) ; shiftRight ( right . bytes , this . bitLength , result . bytes ) ; return result ; } | Concatenate bits . |
18,316 | public Bits range ( final int start , final int length ) { if ( 0 == length ) { return Bits . NULL ; } if ( start < 0 ) { throw new IllegalArgumentException ( ) ; } if ( start + length > this . bitLength ) { throw new IllegalArgumentException ( ) ; } final Bits returnValue = new Bits ( new byte [ ( int ) Math . ceil ( length / 8. ) ] , length ) ; shiftLeft ( this . bytes , start , returnValue . bytes ) ; int bitsInLastByte = length % 8 ; if ( 0 == bitsInLastByte ) { bitsInLastByte = 8 ; } returnValue . bytes [ returnValue . bytes . length - 1 ] &= 0xFF << 8 - bitsInLastByte ; return returnValue ; } | Range bits . |
18,317 | public boolean startsWith ( final Bits key ) { if ( key . bitLength > this . bitLength ) { return false ; } final Bits prefix = key . bitLength < this . bitLength ? this . range ( 0 , key . bitLength ) : this ; return prefix . compareTo ( key ) == 0 ; } | Starts run boolean . |
18,318 | public String toBitString ( ) { StringBuffer sb = new StringBuffer ( ) ; final int shift = this . bytes . length * 8 - this . bitLength ; final byte [ ] shiftRight = shiftRight ( this . bytes , shift ) ; for ( final byte b : shiftRight ) { String asString = Integer . toBinaryString ( b & 0xFF ) ; while ( asString . length ( ) < 8 ) { asString = "0" + asString ; } sb . append ( asString ) ; } if ( sb . length ( ) >= this . bitLength ) { return sb . substring ( sb . length ( ) - this . bitLength , sb . length ( ) ) ; } else { final String n = sb . toString ( ) ; sb = new StringBuffer ( ) ; while ( sb . length ( ) + n . length ( ) < this . bitLength ) { sb . append ( "0" ) ; } return sb + n ; } } | To bit string string . |
18,319 | public String toHexString ( ) { final StringBuffer sb = new StringBuffer ( ) ; for ( final byte b : this . bytes ) { sb . append ( Integer . toHexString ( b & 0xFF ) ) ; } return sb . substring ( 0 , Math . min ( this . bitLength / 4 , sb . length ( ) ) ) ; } | To hex string string . |
18,320 | public long toLong ( ) { long value = 0 ; for ( final byte b : shiftRight ( this . bytes , this . bytes . length * 8 - this . bitLength ) ) { final long shifted = value << 8 ; value = shifted ; final int asInt = b & 0xFF ; value += asInt ; } return value ; } | To long long . |
18,321 | public static ServiceInstanceQuery toServiceInstanceQuery ( String cli ) { char [ ] delimiters = { ';' } ; ServiceInstanceQuery query = new ServiceInstanceQuery ( ) ; for ( String statement : splitStringByDelimiters ( cli , delimiters , false ) ) { QueryCriterion criterion = toQueryCriterion ( statement ) ; if ( criterion != null ) { query . addQueryCriterion ( criterion ) ; } } ; return query ; } | Parse the ServiceInstanceQuery from commandline String expression . |
18,322 | public static String queryToExpressionStr ( ServiceInstanceQuery query ) { List < QueryCriterion > criteria = query . getCriteria ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( QueryCriterion criterion : criteria ) { String statement = criterionToExpressionStr ( criterion ) ; if ( statement != null && ! statement . isEmpty ( ) ) { sb . append ( statement ) . append ( ";" ) ; } } return sb . toString ( ) ; } | Convert the ServiceInstanceQuery to the commandline string expression . |
18,323 | public synchronized Response get ( long timeout , TimeUnit unit ) throws InterruptedException , ExecutionException , TimeoutException { long now = System . currentTimeMillis ( ) ; long mills = unit . toMillis ( timeout ) ; long toWait = mills ; if ( this . completed ) { return this . getResult ( ) ; } else if ( toWait <= 0 ) { throw new TimeoutException ( "Timeout is smaller than 0." ) ; } else { for ( ; ; ) { wait ( toWait ) ; if ( this . completed ) { return this . getResult ( ) ; } long gap = System . currentTimeMillis ( ) - now ; toWait = toWait - gap ; if ( toWait <= 0 ) { throw new TimeoutException ( ) ; } } } } | Get the Directory Request Response . |
18,324 | public synchronized boolean complete ( Response result ) { if ( completed ) { return false ; } completed = true ; this . result = result ; notifyAll ( ) ; return true ; } | Complete the Future . |
18,325 | public synchronized boolean fail ( ServiceException ex ) { if ( completed ) { return false ; } this . completed = true ; this . ex = ex ; notifyAll ( ) ; return true ; } | Fail the Future . |
18,326 | protected boolean mutatesTo ( Object o1 , Object o2 ) { return null != o1 && null != o2 && o1 . getClass ( ) == o2 . getClass ( ) ; } | Determines whether one object mutates to the other object . One object is considered able to mutate to another object if they are indistinguishable in terms of behaviors of all public APIs . The default implementation here is to return true only if the two objects are instances of the same class . |
18,327 | public void writeObject ( Object oldInstance , Encoder out ) { Object newInstance = out . get ( oldInstance ) ; Class < ? > clazz = oldInstance . getClass ( ) ; if ( mutatesTo ( oldInstance , newInstance ) ) { initialize ( clazz , oldInstance , newInstance , out ) ; } else { out . remove ( oldInstance ) ; out . writeExpression ( instantiate ( oldInstance , out ) ) ; newInstance = out . get ( oldInstance ) ; if ( newInstance != null ) { initialize ( clazz , oldInstance , newInstance , out ) ; } } } | Writes a bean object to the given encoder . First it is checked whether the simulating new object can be mutated to the old instance . If yes it is initialized to produce a series of expressions and statements that can be used to restore the old instance . Otherwise remove the new object in the simulating new environment and writes an expression that can instantiate a new instance of the same type as the old one to the given encoder . |
18,328 | private synchronized static void fillCache ( Class objectClass , Map < Class < ? extends Annotation > , IModifier > processors ) { if ( cache . containsKey ( objectClass ) ) { return ; } final Map < Field , Set < Class < ? extends Annotation > > > classCache = new HashMap < > ( ) ; cache . put ( objectClass , classCache ) ; for ( Field field : getAllFields ( objectClass ) ) { final Set < Class < ? extends Annotation > > fieldCache = new HashSet < > ( ) ; for ( Annotation annotation : field . getAnnotations ( ) ) { final Class < ? extends Annotation > annotationType = annotation . annotationType ( ) ; if ( processors . containsKey ( annotationType ) ) { fieldCache . add ( annotationType ) ; } } if ( ! fieldCache . isEmpty ( ) ) { classCache . put ( field , fieldCache ) ; } } } | Fills the annotation cache for the specified class . This scans all fields of the class and checks if they have modifier annotations . This information is saved in a synchronized static cache . |
18,329 | private static List < Field > getAllFields ( Class type ) { final List < Field > fields = new ArrayList < > ( ) ; for ( Class < ? > c = type ; c != null ; c = c . getSuperclass ( ) ) { fields . addAll ( Arrays . asList ( c . getDeclaredFields ( ) ) ) ; } return fields ; } | Returns the declared and inherited fields of the specified class . |
18,330 | @ SuppressWarnings ( "unchecked" ) protected void configure ( ) { for ( Field field : getClass ( ) . getDeclaredFields ( ) ) { if ( IModifier . class . isAssignableFrom ( field . getType ( ) ) ) { try { field . setAccessible ( true ) ; final IModifier processor = ( IModifier ) field . get ( this ) ; processorsCache . put ( processor . getAnnotationType ( ) , processor ) ; } catch ( IllegalArgumentException | IllegalAccessException ex ) { LoggerFactory . getLogger ( ModifiersPreprocessor . class ) . error ( "Could not register pre-processor for field " + field . getName ( ) ) ; } } } } | Registers all preprocessors injected into this class . |
18,331 | @ Requires ( "kind != null" ) @ Ensures ( { "result != null" , "!result.contains(null)" } ) List < ClassContractHandle > getClassHandles ( ContractKind kind ) { ArrayList < ClassContractHandle > matched = new ArrayList < ClassContractHandle > ( ) ; for ( ClassContractHandle h : classHandles ) { if ( kind . equals ( h . getKind ( ) ) ) { matched . add ( h ) ; } } return matched ; } | Returns the ClassHandle objects matching the specified criteria . |
18,332 | @ Requires ( { "kind != null" , "name != null" , "desc != null" , "extraCount >= 0" } ) @ Ensures ( { "result != null" , "!result.contains(null)" } ) List < MethodContractHandle > getMethodHandles ( ContractKind kind , String name , String desc , int extraCount ) { ArrayList < MethodContractHandle > candidates = methodHandles . get ( name ) ; if ( candidates == null ) { return Collections . emptyList ( ) ; } ArrayList < MethodContractHandle > matched = new ArrayList < MethodContractHandle > ( ) ; for ( MethodContractHandle h : candidates ) { if ( kind . equals ( h . getKind ( ) ) && descArgumentsMatch ( desc , h . getContractMethod ( ) . desc , extraCount ) ) { matched . add ( h ) ; } } return matched ; } | Returns the MethodHandle objects matching the specified criteria . |
18,333 | @ Requires ( "kind != null" ) ClassContractHandle getClassHandle ( ContractKind kind ) { ArrayList < ClassContractHandle > matched = new ArrayList < ClassContractHandle > ( ) ; for ( ClassContractHandle h : classHandles ) { if ( kind . equals ( h . getKind ( ) ) ) { return h ; } } return null ; } | Returns the first ClassHandle object matching the specified criteria . |
18,334 | @ Requires ( { "kind != null" , "name != null" , "desc != null" , "extraCount >= 0" } ) MethodContractHandle getMethodHandle ( ContractKind kind , String name , String desc , int extraCount ) { ArrayList < MethodContractHandle > candidates = methodHandles . get ( name ) ; if ( candidates == null ) { return null ; } for ( MethodContractHandle h : candidates ) { if ( kind . equals ( h . getKind ( ) ) && descArgumentsMatch ( desc , h . getContractMethod ( ) . desc , extraCount ) ) { return h ; } } return null ; } | Returns the first MethodHandle object matching the specified criteria . |
18,335 | @ Ensures ( "lastMethodNode == null" ) protected void captureLastMethodNode ( ) { if ( lastMethodNode == null ) { return ; } ContractKind kind = ContractMethodSignatures . getKind ( lastMethodNode ) ; if ( kind != null ) { List < Long > lineNumbers = ContractMethodSignatures . getLineNumbers ( lastMethodNode ) ; if ( kind . isClassContract ( ) || kind . isHelperContract ( ) ) { ClassContractHandle ch = new ClassContractHandle ( kind , className , lastMethodNode , lineNumbers ) ; classHandles . add ( ch ) ; } else { MethodContractHandle mh = new MethodContractHandle ( kind , className , lastMethodNode , lineNumbers ) ; internMethod ( mh . getMethodName ( ) ) . add ( mh ) ; } } lastMethodNode = null ; } | Creates a contract handle for the method last visited if it was a contract method . |
18,336 | public int compareTo ( ParserAction other ) { int result = this . action . compareTo ( other . action ) ; if ( result != 0 ) { return result ; } return other . parameter - this . parameter ; } | This comparison is used to sort parser action lists for ambiguous grammars to get the order of fastest progress . |
18,337 | public static synchronized RenderEngine getInstance ( String name ) { if ( null == availableEngines ) { availableEngines = new HashMap ( ) ; } return ( RenderEngine ) availableEngines . get ( name ) ; } | Get an instance of a RenderEngine . This is a factory method . |
18,338 | public static synchronized RenderEngine getInstance ( ) { if ( null == availableEngines ) { availableEngines = new HashMap ( ) ; } if ( ! availableEngines . containsKey ( DEFAULT ) ) { RenderEngine engine = new BaseRenderEngine ( ) ; availableEngines . put ( engine . getName ( ) , engine ) ; } return ( RenderEngine ) availableEngines . get ( DEFAULT ) ; } | Get an instance of a RenderEngine . This is a factory method . Defaults to a default RenderEngine . Currently this is a basic EngineManager with no additional features that is distributed with Radeox . |
18,339 | public static void clearOne ( String correlationId , Object component ) throws ApplicationException { if ( component instanceof ICleanable ) ( ( ICleanable ) component ) . clear ( correlationId ) ; } | Clears state of specific component . |
18,340 | public static void clear ( String correlationId , Iterable < Object > components ) throws ApplicationException { if ( components == null ) return ; for ( Object component : components ) clearOne ( correlationId , component ) ; } | Clears state of multiple components . |
18,341 | synchronized public boolean connect ( InetSocketAddress addr ) { long now = System . currentTimeMillis ( ) ; if ( isStarted ) { return true ; } isStarted = true ; String host = addr . getHostName ( ) ; int port = addr . getPort ( ) ; serverURI = URI . create ( "ws://" + host + ":" + port + "/ws/service/" ) ; if ( LOGGER . isTraceEnabled ( ) ) { LOGGER . trace ( "WebSocket connect to timeOut=" + connectTimeOut + " - " + serverURI . toString ( ) ) ; } client = new WebSocketClient ( ) ; doConnect ( ) ; synchronized ( sessionLock ) { long to = connectTimeOut - ( System . currentTimeMillis ( ) - now ) ; while ( ! connected && to > 0 ) { try { sessionLock . wait ( to ) ; } catch ( InterruptedException e ) { } to = connectTimeOut - ( System . currentTimeMillis ( ) - now ) ; } } return true ; } | Connect to the remote socket . |
18,342 | synchronized public void cleanup ( ) { LOGGER . info ( "Cleanup the DirectorySocket." ) ; if ( task != null ) { task . toStop ( ) ; task = null ; } if ( client != null ) { try { client . stop ( ) ; } catch ( Exception e ) { LOGGER . warn ( "Close WebSocketClient get exception." , e ) ; } client = null ; } try { if ( session != null ) { session . close ( ) ; } } catch ( IOException e ) { LOGGER . warn ( "Close the WebSocket Session get exception." , e ) ; } if ( sessionFuture != null ) { try { sessionFuture . cancel ( true ) ; } catch ( Exception e ) { } } session = null ; sessionFuture = null ; websocketStarted = false ; connected = false ; isStarted = false ; } | Cleanup the DirectorySocket to original status to connect to another Socket . |
18,343 | private void doConnect ( ) { task = new SocketDeamonTask ( ) ; connectThread = new Thread ( task ) ; connectThread . setDaemon ( true ) ; connectThread . start ( ) ; } | Do the WebSocket connect . |
18,344 | private Priority parsePriority ( final String warningTypeString ) { if ( StringUtils . equalsIgnoreCase ( warningTypeString , "notice" ) ) { return Priority . LOW ; } else if ( StringUtils . equalsIgnoreCase ( warningTypeString , "warning" ) ) { return Priority . NORMAL ; } else if ( StringUtils . equalsIgnoreCase ( warningTypeString , "error" ) ) { return Priority . HIGH ; } else { return Priority . HIGH ; } } | Returns the priority ordinal matching the specified warning type string . |
18,345 | public long getTake ( long maxTake ) { if ( _take == null ) return maxTake ; if ( _take < 0 ) return 0 ; if ( _take > maxTake ) return maxTake ; return _take ; } | Gets the number of items to return in a page . |
18,346 | public static PagingParams fromValue ( Object value ) { if ( value instanceof PagingParams ) return ( PagingParams ) value ; AnyValueMap map = AnyValueMap . fromValue ( value ) ; return PagingParams . fromMap ( map ) ; } | Converts specified value into PagingParams . |
18,347 | public static PagingParams fromTuples ( Object ... tuples ) { AnyValueMap map = AnyValueMap . fromTuples ( tuples ) ; return PagingParams . fromMap ( map ) ; } | Creates a new PagingParams from a list of key - value pairs called tuples . |
18,348 | public static PagingParams fromMap ( AnyValueMap map ) { Long skip = map . getAsNullableLong ( "skip" ) ; Long take = map . getAsNullableLong ( "take" ) ; boolean total = map . getAsBooleanWithDefault ( "total" , true ) ; return new PagingParams ( skip , take , total ) ; } | Creates a new PagingParams and sets it parameters from the AnyValueMap map |
18,349 | public static synchronized CollectorController createHttpController ( final String collectorHost , final int collectorPort , final EventType eventType , final long httpMaxWaitTimeInMillis , final long httpMaxKeepAliveInMillis , final String spoolDirectoryName , final boolean isFlushEnabled , final int flushIntervalInSeconds , final SyncType syncType , final int syncBatchSize , final long maxUncommittedWriteCount , final int maxUncommittedPeriodInSeconds , final int httpWorkersPoolSize ) throws IOException { if ( singletonController == null ) { singletonController = new HttpCollectorFactory ( collectorHost , collectorPort , eventType , httpMaxWaitTimeInMillis , httpMaxKeepAliveInMillis , spoolDirectoryName , isFlushEnabled , flushIntervalInSeconds , syncType , syncBatchSize , maxUncommittedWriteCount , maxUncommittedPeriodInSeconds , httpWorkersPoolSize ) . get ( ) ; } return singletonController ; } | Factory method for tests cases |
18,350 | @ SuppressWarnings ( "nls" ) private void checkNotNull ( Object sourceClass , Object eventSetName , Object alistenerType , Object listenerMethodName ) { if ( sourceClass == null ) { throw new NullPointerException ( Messages . getString ( "beans.0C" ) ) ; } if ( eventSetName == null ) { throw new NullPointerException ( Messages . getString ( "beans.53" ) ) ; } if ( alistenerType == null ) { throw new NullPointerException ( Messages . getString ( "beans.54" ) ) ; } if ( listenerMethodName == null ) { throw new NullPointerException ( Messages . getString ( "beans.52" ) ) ; } } | ensures that there is no nulls |
18,351 | public URIBuilder appendFilter ( URIBuilder builder , Collection < Filter < ? > > filters ) { if ( filters . size ( ) > 0 ) { ObjectNode filterNode = new ObjectMapper ( ) . createObjectNode ( ) ; for ( Filter < ? > filter : filters ) { filterNode . setAll ( filter . toJson ( ) ) ; } ObjectNode drilldownNode = new ObjectMapper ( ) . createObjectNode ( ) ; drilldownNode . put ( "drilldown" , filterNode ) ; builder . addParameter ( "filter" , drilldownNode . toString ( ) ) ; } return builder ; } | Appends a filter parameter from the given filters to the URI builder . Won t do anything if the filter collection is empty . |
18,352 | private void readObject ( ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; try { Field domainList = getClass ( ) . getDeclaredField ( "domainList" ) ; domainList . setAccessible ( true ) ; domainList . set ( this , new DomainList ( ) ) ; Field dashboardList = getClass ( ) . getDeclaredField ( "dashboardList" ) ; dashboardList . setAccessible ( true ) ; dashboardList . set ( this , new DashboardList ( ) ) ; Field reportList = getClass ( ) . getDeclaredField ( "reportList" ) ; reportList . setAccessible ( true ) ; reportList . set ( this , new ReportList ( ) ) ; Field dataSetList = getClass ( ) . getDeclaredField ( "dataSetList" ) ; dataSetList . setAccessible ( true ) ; dataSetList . set ( this , new DataSetList ( ) ) ; Field commentLists = getClass ( ) . getDeclaredField ( "commentLists" ) ; commentLists . setAccessible ( true ) ; commentLists . set ( this , Collections . synchronizedMap ( new HashMap < String , PaginatedList < Comment > > ( ) ) ) ; Field reportAttributeValues = getClass ( ) . getDeclaredField ( "dataSetAttributeValues" ) ; reportAttributeValues . setAccessible ( true ) ; reportAttributeValues . set ( this , new HashMap < String , Map < String , CachedListImpl < AttributeValue > > > ( ) ) ; Field dataSourceList = getClass ( ) . getDeclaredField ( "dataSourceList" ) ; dataSourceList . setAccessible ( true ) ; dataSourceList . set ( this , new HashMap < String , CachedListImpl < DataSource > > ( ) ) ; Field importFormList = getClass ( ) . getDeclaredField ( "importFormList" ) ; importFormList . setAccessible ( true ) ; importFormList . set ( this , new ImportFormList ( ) ) ; Field dataSourceImportList = getClass ( ) . getDeclaredField ( "dataSourceImportList" ) ; dataSourceImportList . setAccessible ( true ) ; dataSourceImportList . set ( this , new HashMap < String , CachedListImpl < DataSourceImport > > ( ) ) ; } catch ( NoSuchFieldException e ) { throw new InternalConfigurationException ( "Failed to set service fields" , e ) ; } catch ( IllegalAccessException e ) { throw new InternalConfigurationException ( "Failed to set service fields" , e ) ; } catch ( SecurityException e ) { throw new InternalConfigurationException ( "Failed to set service fields" , e ) ; } catch ( IllegalArgumentException e ) { throw new InternalConfigurationException ( "Failed to set service fields" , e ) ; } } | Deserialization . Sets up the element lists and maps as empty objects . |
18,353 | public < T > Future < T > submit ( Callable < T > callable ) { checkThreadQueue ( ) ; return threadPool . submit ( callable ) ; } | Submit future . |
18,354 | public static MaskedText maskInUrl ( String url ) { MaskedText result = new MaskedText ( ) ; result . setClearText ( url ) ; result . setText ( url ) ; result . setMasked ( null ) ; if ( url != null ) { Matcher urlMatcher = URL_PATTERN . matcher ( url ) ; if ( urlMatcher . find ( ) ) { Matcher pwdMatcher = PASSWORD_IN_URL_PATTERN . matcher ( url ) ; if ( pwdMatcher . find ( ) ) { result . setText ( pwdMatcher . replaceFirst ( PASSWORD_IN_URL_MASK ) ) ; String s = pwdMatcher . group ( ) ; result . setMasked ( s . substring ( 1 , s . length ( ) - 1 ) ) ; } } } return result ; } | Mask password in URL . |
18,355 | public static String unmaskInUrl ( String url , String password ) { String result = null ; if ( url != null ) { Matcher urlMatcher = URL_PATTERN . matcher ( url ) ; if ( urlMatcher . find ( ) ) { int s = url . indexOf ( PASSWORD_IN_URL_MASK ) ; if ( s >= 0 ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( url . substring ( 0 , s ) ) ; if ( password != null ) { sb . append ( ':' ) . append ( password ) ; } sb . append ( '@' ) ; sb . append ( url . substring ( s + PASSWORD_IN_URL_MASK . length ( ) , url . length ( ) ) ) ; result = sb . toString ( ) ; } } } return result == null ? url : result ; } | Unmask password in URL . |
18,356 | public double getNumber ( long timestamp , Function < CountBytesSizeAccumulator , Long > valueFunction ) { return JMOptional . getOptional ( this , timestamp ) . map ( valueFunction ) . map ( ( Long :: doubleValue ) ) . orElse ( 0d ) ; } | Gets number . |
18,357 | public Parameter param ( String key ) { if ( mParams == null ) { return null ; } Parameter value = mParams . get ( key ) ; return value != null ? value : mParams . get ( key . toLowerCase ( Locale . ENGLISH ) ) ; } | Return the parameter value for a specific key . |
18,358 | @ SuppressWarnings ( "unchecked" ) public static Map < String , Object > toNullableMap ( Object value ) { if ( value == null ) return null ; Class < ? > valueClass = value . getClass ( ) ; if ( valueClass . isPrimitive ( ) ) return null ; if ( value instanceof Map < ? , ? > ) return mapToMap ( ( Map < Object , Object > ) value ) ; if ( valueClass . isArray ( ) ) return arrayToMap ( ( Object [ ] ) value ) ; if ( value instanceof Collection < ? > ) return listToMap ( ( Collection < Object > ) value ) ; try { return mapper . convertValue ( value , typeRef ) ; } catch ( Exception ex ) { return null ; } } | Converts value into map object or returns null when conversion is not possible . |
18,359 | public static byte [ ] convertObjectToByteArray ( Object o ) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( bos ) ; oos . writeObject ( o ) ; return bos . toByteArray ( ) ; } | Konvertiert ein beliebiges Objekt in ein byte - Array . |
18,360 | public static InputStream convertObjectToInputStream ( Object o ) throws IOException { byte [ ] bObject = convertObjectToByteArray ( o ) ; return new ByteArrayInputStream ( bObject ) ; } | Konvertiert ein beliebiges Objekt in ein byte - Array und schleust dieses durch ein InputStream . |
18,361 | public static Object convertInputStreamToObject ( InputStream is ) throws IOException , ClassNotFoundException { ObjectInputStream ois = new ObjectInputStream ( is ) ; return ois . readObject ( ) ; } | Liest aus einen Inputstream ein Object aus . |
18,362 | static public String getBasicAuthUsername ( HttpServletRequest request ) { String [ ] userAndPassword = getBasicAuthUsernameAndPassword ( request ) ; return userAndPassword == null || userAndPassword . length == 0 ? null : userAndPassword [ 0 ] ; } | Get the user name in the basic authentication header |
18,363 | static public String [ ] getBasicAuthUsernameAndPassword ( HttpServletRequest request ) { String authorization = request . getHeader ( "Authorization" ) ; if ( authorization != null && authorization . startsWith ( "Basic" ) ) { try { String base64Credentials = authorization . substring ( "Basic" . length ( ) ) . trim ( ) ; String credentials = new String ( Base64 . decode ( base64Credentials ) , "UTF-8" ) ; String [ ] values = StringUtils . split ( credentials , ':' ) ; return values ; } catch ( Exception e ) { } } return null ; } | Get the user name and password passed in the basic authentication header . |
18,364 | static public boolean isFromLocalhost ( HttpServletRequest request ) { String addr = request . getRemoteAddr ( ) ; return "0:0:0:0:0:0:0:1" . equals ( addr ) || "::1" . equals ( addr ) || ( addr != null && addr . startsWith ( "127." ) ) ; } | Check to see if the request is from localhost |
18,365 | public static List < Permission > id2Permissions ( int id ) { List < Permission > list = new ArrayList < Permission > ( ) ; if ( id <= 0 || id > 31 ) { list . add ( Permission . NONE ) ; } else { if ( ( id & Permission . READ . getId ( ) ) != 0 ) { list . add ( Permission . READ ) ; } if ( ( id & Permission . WRITE . getId ( ) ) != 0 ) { list . add ( Permission . WRITE ) ; } if ( ( id & Permission . CREATE . getId ( ) ) != 0 ) { list . add ( Permission . CREATE ) ; } if ( ( id & Permission . DELETE . getId ( ) ) != 0 ) { list . add ( Permission . DELETE ) ; } if ( ( id & Permission . ADMIN . getId ( ) ) != 0 ) { list . add ( Permission . ADMIN ) ; } } return list ; } | Transfer the permission id to Permission list . |
18,366 | public static int permissionList2Id ( List < Permission > permissions ) { int id = 0 ; if ( permissions != null && ! permissions . isEmpty ( ) ) { for ( Permission p : permissions ) { id += p . getId ( ) ; } } return id ; } | Transfer the Permission List to id . |
18,367 | public static int permissionArray2Id ( Permission [ ] permissions ) { int id = 0 ; if ( permissions != null && permissions . length != 0 ) { for ( Permission p : permissions ) { id += p . getId ( ) ; } } return id ; } | Transfer the Permission Array to id . |
18,368 | public static String toNullableString ( Object value ) { if ( value == null ) return null ; if ( value instanceof String ) return ( String ) value ; if ( value instanceof Date ) value = ZonedDateTime . ofInstant ( ( ( Date ) value ) . toInstant ( ) , ZoneId . systemDefault ( ) ) ; if ( value instanceof Calendar ) { value = ZonedDateTime . ofInstant ( ( ( Calendar ) value ) . toInstant ( ) , ( ( Calendar ) value ) . getTimeZone ( ) . toZoneId ( ) ) ; } if ( value instanceof Duration ) value = ( ( Duration ) value ) . toMillis ( ) ; if ( value instanceof Instant ) value = ZonedDateTime . ofInstant ( ( Instant ) value , ZoneId . systemDefault ( ) ) ; if ( value instanceof LocalDateTime ) value = ZonedDateTime . of ( ( LocalDateTime ) value , ZoneId . systemDefault ( ) ) ; if ( value instanceof LocalDate ) value = ZonedDateTime . of ( ( LocalDate ) value , LocalTime . of ( 0 , 0 ) , ZoneId . systemDefault ( ) ) ; if ( value instanceof ZonedDateTime ) return ( ( ZonedDateTime ) value ) . format ( DateTimeFormatter . ISO_OFFSET_DATE_TIME ) ; if ( value instanceof List < ? > ) { StringBuilder builder = new StringBuilder ( ) ; for ( Object element : ( List < ? > ) value ) { if ( builder . length ( ) > 0 ) builder . append ( "," ) ; builder . append ( element ) ; } return builder . toString ( ) ; } if ( value . getClass ( ) . isArray ( ) ) { StringBuilder builder = new StringBuilder ( ) ; int length = Array . getLength ( value ) ; for ( int index = 0 ; index < length ; index ++ ) { if ( builder . length ( ) > 0 ) builder . append ( "," ) ; builder . append ( Array . get ( value , index ) ) ; } return builder . toString ( ) ; } return value . toString ( ) ; } | Converts value into string or returns null when value is null . |
18,369 | public static String toStringWithDefault ( Object value , String defaultValue ) { String result = toNullableString ( value ) ; return result != null ? result : defaultValue ; } | Converts value into string or returns default when value is null . |
18,370 | public static HttpRequestBase get ( String path , Map < String , String > headers , Integer timeOutInSeconds ) { HttpGet get = new HttpGet ( path ) ; addHeaders ( get , headers ) ; get . setConfig ( getConfig ( timeOutInSeconds ) ) ; return get ; } | Step 1 . prepare GET request |
18,371 | public static HttpRequestBase post ( String path , Map < String , String > headers , Map < String , String > parameters , HttpEntity entity , Integer timeOutInSeconds ) { HttpPost post = new HttpPost ( path ) ; addHeaders ( post , headers ) ; addParameters ( post , parameters ) ; post . setConfig ( getConfig ( timeOutInSeconds ) ) ; if ( entity != null ) { post . setEntity ( entity ) ; } return post ; } | Step 1 . prepare POST request |
18,372 | public static HttpRequestBase patch ( String path , Map < String , String > headers , Map < String , String > parameters , HttpEntity entity , Integer timeOutInSeconds ) { HttpPatch patch = new HttpPatch ( path ) ; addHeaders ( patch , headers ) ; addParameters ( patch , parameters ) ; patch . setConfig ( getConfig ( timeOutInSeconds ) ) ; if ( entity != null ) { patch . setEntity ( entity ) ; } return patch ; } | Step 1 . prepare PATCH request |
18,373 | public static HttpRequestBase delete ( String path , Map < String , String > headers , Integer timeOutInSeconds ) { HttpDelete delete = new HttpDelete ( path ) ; addHeaders ( delete , headers ) ; delete . setConfig ( getConfig ( timeOutInSeconds ) ) ; return delete ; } | Step 1 . prepare DELETE request |
18,374 | public static HttpResponse execute ( HttpRequestBase request ) throws IOException { Assert . notNull ( request , "Missing request!" ) ; HttpClient client = HttpClientBuilder . create ( ) . setRedirectStrategy ( new DefaultRedirectStrategy ( ) ) . build ( ) ; return client . execute ( request ) ; } | Step 2 . execute request |
18,375 | public static void executeAsync ( Executor executor , HttpRequestBase request , FutureCallback < HttpResponse > callback ) { try { executor . execute ( new AsyncHttpCall ( request , callback ) ) ; } catch ( Exception e ) { log . error ( "Failed to execute asynchronously: " + request . getMethod ( ) + " " + request . getURI ( ) . toString ( ) ) ; } } | Step 2 . execute request asynchronously |
18,376 | public static boolean matchValue ( Object expectedType , Object actualValue ) { if ( expectedType == null ) return true ; if ( actualValue == null ) throw new NullPointerException ( "Actual value cannot be null" ) ; return matchType ( expectedType , actualValue . getClass ( ) ) ; } | Matches expected type to a type of a value . The expected type can be specified by a type type name or TypeCode . |
18,377 | public static boolean matchType ( Object expectedType , Class < ? > actualType ) { if ( expectedType == null ) return true ; if ( actualType == null ) throw new NullPointerException ( "Actual type cannot be null" ) ; if ( expectedType instanceof Class < ? > ) return ( ( Class < ? > ) expectedType ) . isAssignableFrom ( actualType ) ; if ( expectedType instanceof String ) return matchTypeByName ( ( String ) expectedType , actualType ) ; if ( expectedType instanceof TypeCode ) return TypeConverter . toTypeCode ( actualType ) . equals ( expectedType ) ; return false ; } | Matches expected type to an actual type . The types can be specified as types type names or TypeCode . |
18,378 | public static boolean matchValueByName ( String expectedType , Object actualValue ) { if ( expectedType == null ) return true ; if ( actualValue == null ) throw new NullPointerException ( "Actual value cannot be null" ) ; return matchTypeByName ( expectedType , actualValue . getClass ( ) ) ; } | Matches expected type to a type of a value . |
18,379 | public static boolean matchTypeByName ( String expectedType , Class < ? > actualType ) { if ( expectedType == null ) return true ; if ( actualType == null ) throw new NullPointerException ( "Actual type cannot be null" ) ; expectedType = expectedType . toLowerCase ( ) ; if ( actualType . getName ( ) . equalsIgnoreCase ( expectedType ) ) return true ; else if ( actualType . getSimpleName ( ) . equalsIgnoreCase ( expectedType ) ) return true ; else if ( expectedType . equals ( "object" ) ) return true ; else if ( expectedType . equals ( "int" ) || expectedType . equals ( "integer" ) ) { return Integer . class . isAssignableFrom ( actualType ) || Long . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . equals ( "long" ) ) { return Long . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . equals ( "float" ) ) { return Float . class . isAssignableFrom ( actualType ) || Double . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . equals ( "double" ) ) { return Double . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . equals ( "string" ) ) { return String . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . equals ( "bool" ) || expectedType . equals ( "boolean" ) ) { return Boolean . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . equals ( "date" ) || expectedType . equals ( "datetime" ) ) { return Date . class . isAssignableFrom ( actualType ) || Calendar . class . isAssignableFrom ( actualType ) || ZonedDateTime . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . equals ( "timespan" ) || expectedType . equals ( "duration" ) ) { return Integer . class . isAssignableFrom ( actualType ) || Long . class . isAssignableFrom ( actualType ) || Float . class . isAssignableFrom ( actualType ) || Double . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . equals ( "enum" ) ) { return Enum . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . equals ( "map" ) || expectedType . equals ( "dict" ) || expectedType . equals ( "dictionary" ) ) { return Map . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . equals ( "array" ) || expectedType . equals ( "list" ) ) { return actualType . isArray ( ) || List . class . isAssignableFrom ( actualType ) ; } else if ( expectedType . endsWith ( "[]" ) ) { return actualType . isArray ( ) || List . class . isAssignableFrom ( actualType ) ; } else return false ; } | Matches expected type to an actual type . |
18,380 | public static TorchFactory with ( DatabaseEngine engine ) { Validate . isNull ( factoryInstance , "Call TorchService#forceUnload if you want to reload TorchFactory!" ) ; factoryInstance = new TorchFactoryImpl ( engine ) ; return factoryInstance ; } | Loads the TorchFactory with passed context . In order to get all async callbacks delivered on UI Thread you have to call this on UI Thread |
18,381 | public static void forceUnload ( ) { if ( factoryInstance != null ) { factoryInstance . unload ( ) ; } STACK . get ( ) . clear ( ) ; factoryInstance = null ; } | Use this to force unload Torch . Probably used in tests only . |
18,382 | public static Torch torch ( ) { if ( ! isLoaded ( ) ) { throw new IllegalStateException ( "Factory is not loaded!" ) ; } LinkedList < Torch > stack = STACK . get ( ) ; if ( stack . isEmpty ( ) ) { stack . add ( factoryInstance . begin ( ) ) ; } return stack . getLast ( ) ; } | This is the main method that will initialize the Torch . |
18,383 | public static Boolean toNullableBoolean ( Object value ) { if ( value == null ) return null ; if ( value instanceof Boolean ) return ( boolean ) value ; if ( value instanceof Duration ) return ( ( Duration ) value ) . toMillis ( ) > 0 ; String strValue = value . toString ( ) . toLowerCase ( ) ; if ( strValue . equals ( "1" ) || strValue . equals ( "true" ) || strValue . equals ( "t" ) || strValue . equals ( "yes" ) || strValue . equals ( "y" ) ) return true ; if ( strValue . equals ( "0" ) || strValue . equals ( "false" ) || strValue . equals ( "f" ) || strValue . equals ( "no" ) || strValue . equals ( "n" ) ) return false ; return null ; } | Converts value into boolean or returns null when conversion is not possible . |
18,384 | public static boolean toBooleanWithDefault ( Object value , boolean defaultValue ) { Boolean result = toNullableBoolean ( value ) ; return result != null ? ( boolean ) result : defaultValue ; } | Converts value into boolean or returns default value when conversion is not possible |
18,385 | public static ImmutableConfig copyOf ( Config config ) { if ( config instanceof ImmutableConfig ) { return ( ImmutableConfig ) config ; } else { return new ImmutableConfig ( config ) ; } } | Create an immutable config instance . |
18,386 | private CachedProviderServiceInstance getCachedServiceInstance ( String serviceName , String providerAddress ) { ServiceInstanceId id = new ServiceInstanceId ( serviceName , providerAddress ) ; return getCacheServiceInstances ( ) . get ( id ) ; } | Get the Cached ProvidedServiceInstance by serviceName and providerAddress . |
18,387 | private void scheduleTasks ( ) { int rhDelay = getServiceDirectoryConfig ( ) . getInt ( SD_API_REGISTRY_HEALTH_CHECK_DELAY_PROPERTY , SD_API_REGISTRY_HEALTH_CHECK_DELAY_DEFAULT ) ; int rhInterval = getServiceDirectoryConfig ( ) . getInt ( SD_API_REGISTRY_HEALTH_CHECK_INTERVAL_PROPERTY , SD_API_REGISTRY_HEALTH_CHECK_INTERVAL_DEFAULT ) ; LOGGER . info ( "Start the SD API RegistryHealth Task scheduler, delay={}, interval={}." , rhDelay , rhInterval ) ; healthCheckService . get ( ) . scheduleAtFixedRate ( new HealthCheckTask ( ) , rhDelay , rhInterval , TimeUnit . SECONDS ) ; int hbDelay = getServiceDirectoryConfig ( ) . getInt ( SD_API_HEARTBEAT_DELAY_PROPERTY , SD_API_HEARTBEAT_DELAY_DEFAULT ) ; int hbInterval = getServiceDirectoryConfig ( ) . getInt ( SD_API_HEARTBEAT_INTERVAL_PROPERTY , SD_API_HEARTBEAT_INTERVAL_DEFAULT ) ; LOGGER . info ( "Start the SD API Heartbeat Task scheduler, delay={}, interval={}." , hbDelay , hbInterval ) ; heartbeatService . get ( ) . scheduleAtFixedRate ( new HeartbeatTask ( ) , hbDelay , hbInterval , TimeUnit . SECONDS ) ; } | schedule the Heartbeat task and Health Check task . |
18,388 | public static boolean hasProperty ( Object obj , String name ) { if ( obj == null ) throw new NullPointerException ( "Object cannot be null" ) ; if ( name == null ) throw new NullPointerException ( "Property name cannot be null" ) ; Class < ? > objClass = obj . getClass ( ) ; for ( Field field : objClass . getFields ( ) ) { if ( matchField ( field , name ) ) return true ; } name = "get" + name ; for ( Method method : objClass . getMethods ( ) ) { if ( matchPropertyGetter ( method , name ) ) return true ; } return false ; } | Checks if object has a property with specified name .. |
18,389 | public static Object getProperty ( Object obj , String name ) { if ( obj == null ) throw new NullPointerException ( "Object cannot be null" ) ; if ( name == null ) throw new NullPointerException ( "Property name cannot be null" ) ; Class < ? > objClass = obj . getClass ( ) ; for ( Field field : objClass . getFields ( ) ) { try { if ( matchField ( field , name ) ) return field . get ( obj ) ; } catch ( Throwable t ) { } } name = "get" + name ; for ( Method method : objClass . getMethods ( ) ) { try { if ( matchPropertyGetter ( method , name ) ) return method . invoke ( obj ) ; } catch ( Throwable t ) { } } return null ; } | Gets value of object property specified by its name . |
18,390 | public static Map < String , Object > getProperties ( Object obj ) { Map < String , Object > map = new HashMap < String , Object > ( ) ; Class < ? > objClass = obj . getClass ( ) ; for ( Field field : objClass . getFields ( ) ) { try { if ( matchField ( field , field . getName ( ) ) ) { String name = field . getName ( ) ; Object value = field . get ( obj ) ; map . put ( name , value ) ; } } catch ( Throwable t ) { } } for ( Method method : objClass . getMethods ( ) ) { try { if ( method . getName ( ) . startsWith ( "get" ) && matchPropertyGetter ( method , method . getName ( ) ) ) { String name = method . getName ( ) . substring ( 3 ) ; name = name . substring ( 0 , 1 ) . toLowerCase ( ) + name . substring ( 1 ) ; Object value = method . invoke ( obj ) ; map . put ( name , value ) ; } } catch ( Throwable t ) { } } return map ; } | Get values of all properties in specified object and returns them as a map . |
18,391 | public static < T > Optional < T > getOptionalIfTrue ( boolean bool , T target ) { return bool ? Optional . ofNullable ( target ) : Optional . empty ( ) ; } | Gets optional if true . |
18,392 | public static < T > Optional < T > getNullableAndFilteredOptional ( T target , Predicate < T > predicate ) { return Optional . ofNullable ( target ) . filter ( predicate ) ; } | Gets nullable and filtered optional . |
18,393 | public static < K , V , R > Optional < R > getValueAsOptIfExist ( Map < K , V > map , K key , Function < V , R > returnBuilderFunction ) { return getOptional ( map , key ) . map ( returnBuilderFunction :: apply ) ; } | Gets value as opt if exist . |
18,394 | public static < T > void ifNotNull ( T object , Consumer < T > consumer ) { Optional . ofNullable ( object ) . ifPresent ( consumer ) ; } | If not null . |
18,395 | public static < T > T orElseGetIfNull ( T target , Supplier < T > elseGetSupplier ) { return Optional . ofNullable ( target ) . orElseGet ( elseGetSupplier ) ; } | Or else get if null t . |
18,396 | public static < T > T orElseIfNull ( T target , T elseTarget ) { return Optional . ofNullable ( target ) . orElse ( elseTarget ) ; } | Or else if null t . |
18,397 | public static < T , C extends Collection < T > > Stream < T > ifExistIntoStream ( C collection ) { return getOptional ( collection ) . map ( Collection :: stream ) . orElseGet ( Stream :: empty ) ; } | If exist into stream stream . |
18,398 | public static boolean isPresentAll ( Optional < ? > ... optionals ) { for ( Optional < ? > optional : optionals ) if ( ! optional . isPresent ( ) ) return false ; return true ; } | Is present all boolean . |
18,399 | public static < T > List < T > getListIfIsPresent ( Optional < T > ... optionals ) { return Arrays . stream ( optionals ) . filter ( Optional :: isPresent ) . map ( Optional :: get ) . collect ( Collectors . toList ( ) ) ; } | Gets list if is present . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.