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 , ... | 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 ( HttpHe... | 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... | 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 ; } }... | 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 ) << bitPar... | 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... | 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 (... | 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 ( ... | 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 . len... | 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 ( criter... | 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 && ! stateme... | 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 ... | 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 . writeEx... | 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 environme... |
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 , classCach... | 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 . p... | 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 .... | 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 = method... | 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... | 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 ( k... | 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 ) a... | 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 ( LOGGE... | 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 ( se... | 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 ( wa... | 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 flushIntervalInSe... | 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 ( ... | 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 Objec... | 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 ( ... | 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_... | 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 ( ur... | 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 >... | 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 (... | 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 . g... | 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 ) { val... | 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 ( timeOutI... | 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 ( t... | 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 . ge... | 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 (... | 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 ... | 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 (... | 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_INT... | 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 ( ... | 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 ( )... | 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 ( ... | 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.