idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
21,100 | protected List < PropertySource > readPropertySourceListFromFiles ( String files ) { List < PropertySource > propertySources = new ArrayList < > ( ) ; Collection < PropertySourceLoader > propertySourceLoaders = getPropertySourceLoaders ( ) ; Optional < Collection < String > > filePathList = Optional . ofNullable ( files ) . filter ( value -> ! value . isEmpty ( ) ) . map ( value -> value . split ( FILE_SEPARATOR ) ) . map ( Arrays :: asList ) . map ( Collections :: unmodifiableList ) ; filePathList . ifPresent ( list -> { if ( ! list . isEmpty ( ) ) { list . forEach ( filePath -> { if ( ! propertySourceLoaders . isEmpty ( ) ) { String extension = NameUtils . extension ( filePath ) ; String fileName = NameUtils . filename ( filePath ) ; Optional < PropertySourceLoader > propertySourceLoader = Optional . ofNullable ( loaderByFormatMap . get ( extension ) ) ; if ( propertySourceLoader . isPresent ( ) ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Reading property sources from loader: {}" , propertySourceLoader ) ; } readPropertySourceFromLoader ( fileName , filePath , propertySourceLoader . get ( ) , propertySources ) ; } else { throw new ConfigurationException ( "Unsupported properties file format: " + fileName ) ; } } } ) ; } } ) ; return propertySources ; } | Resolve the property sources for files passed via system property and system env . |
21,101 | private void readPropertySourceFromLoader ( String fileName , String filePath , PropertySourceLoader propertySourceLoader , List < PropertySource > propertySources ) throws ConfigurationException { ResourceResolver resourceResolver = new ResourceResolver ( ) ; Optional < ResourceLoader > resourceLoader = resourceResolver . getSupportingLoader ( filePath ) ; ResourceLoader loader = resourceLoader . orElse ( FileSystemResourceLoader . defaultLoader ( ) ) ; try { Optional < InputStream > inputStream = loader . getResourceAsStream ( filePath ) ; if ( inputStream . isPresent ( ) ) { Map < String , Object > properties = propertySourceLoader . read ( fileName , inputStream . get ( ) ) ; propertySources . add ( PropertySource . of ( properties ) ) ; } } catch ( IOException e ) { throw new ConfigurationException ( "Unsupported properties file: " + fileName ) ; } } | Read the property source . |
21,102 | public static < T extends Annotation > AnnotationValueBuilder < T > builder ( Class < T > annotation ) { return new AnnotationValueBuilder < > ( annotation ) ; } | Start building a new annotation for the given name . |
21,103 | private ConvertibleValues < Object > newConvertibleValues ( Map < CharSequence , Object > values ) { if ( CollectionUtils . isEmpty ( values ) ) { return ConvertibleValues . EMPTY ; } else { return ConvertibleValues . of ( values ) ; } } | Subclasses can override to provide a custom convertible values instance . |
21,104 | public static Optional < String > stringValue ( JsonNode json , String key ) { return Optional . ofNullable ( json . findValue ( key ) ) . map ( JsonNode :: asText ) ; } | Resolve a value as a string from the metadata json . |
21,105 | protected List < String > defaultParameterTypes ( Class < ? > [ ] parameterTypes ) { List < String > names = new ArrayList < > ( ) ; for ( int i = 0 ; i < parameterTypes . length ; i ++ ) { names . add ( "arg" + i ) ; } return names ; } | Add the parameter types to a list of names . |
21,106 | protected HealthResult getHealthResult ( ) { HealthResult . Builder builder = HealthResult . builder ( getName ( ) ) ; try { builder . details ( getHealthInformation ( ) ) ; builder . status ( this . healthStatus ) ; } catch ( Exception e ) { builder . status ( HealthStatus . DOWN ) ; builder . exception ( e ) ; } return builder . build ( ) ; } | Builds the whole health result . |
21,107 | long recordRead ( int bufferIndex , Node < K , V > node ) { final AtomicLong counter = readBufferWriteCount [ bufferIndex ] ; final long writeCount = counter . get ( ) ; counter . lazySet ( writeCount + 1 ) ; final int index = ( int ) ( writeCount & READ_BUFFER_INDEX_MASK ) ; readBuffers [ bufferIndex ] [ index ] . lazySet ( node ) ; return writeCount ; } | Records a read in the buffer and return its write count . |
21,108 | void drainOnReadIfNeeded ( int bufferIndex , long writeCount ) { final long pending = ( writeCount - readBufferDrainAtWriteCount [ bufferIndex ] . get ( ) ) ; final boolean delayable = ( pending < READ_BUFFER_THRESHOLD ) ; final DrainStatus status = drainStatus . get ( ) ; if ( status . shouldDrainBuffers ( delayable ) ) { tryToDrainBuffers ( ) ; } } | Attempts to drain the buffers if it is determined to be needed when post - processing a read . |
21,109 | @ GuardedBy ( "evictionLock" ) void drainReadBuffers ( ) { final int start = ( int ) Thread . currentThread ( ) . getId ( ) ; final int end = start + NUMBER_OF_READ_BUFFERS ; for ( int i = start ; i < end ; i ++ ) { drainReadBuffer ( i & READ_BUFFERS_MASK ) ; } } | Drains the read buffers each up to an amortized threshold . |
21,110 | @ GuardedBy ( "evictionLock" ) void drainWriteBuffer ( ) { for ( int i = 0 ; i < WRITE_BUFFER_DRAIN_THRESHOLD ; i ++ ) { final Runnable task = writeBuffer . poll ( ) ; if ( task == null ) { break ; } task . run ( ) ; } } | Drains the read buffer up to an amortized threshold . |
21,111 | void notifyListener ( ) { Node < K , V > node ; while ( ( node = pendingNotifications . poll ( ) ) != null ) { listener . onEviction ( node . key , node . getValue ( ) ) ; } } | Notifies the listener of entries that were evicted . |
21,112 | protected void validateName ( String name , String typeDescription ) { if ( ! APPLICATION_NAME_PATTERN . matcher ( name ) . matches ( ) ) { throw new DiscoveryException ( typeDescription + " [" + name + "] must start with a letter, end with a letter or digit and contain only letters, digits or hyphens. Example: foo-bar" ) ; } } | Validate the given application name . |
21,113 | @ SuppressWarnings ( "unchecked" ) protected BindingResult < T > doBind ( ArgumentConversionContext < T > context , ConvertibleValues < ? > values , String annotationValue ) { return doConvert ( doResolve ( context , values , annotationValue ) , context ) ; } | Do binding . |
21,114 | @ SuppressWarnings ( "unchecked" ) protected Object doResolve ( ArgumentConversionContext < T > context , ConvertibleValues < ? > values , String annotationValue ) { Object value = resolveValue ( context , values , annotationValue ) ; if ( value == null ) { String fallbackName = getFallbackFormat ( context . getArgument ( ) ) ; if ( ! annotationValue . equals ( fallbackName ) ) { annotationValue = fallbackName ; value = resolveValue ( context , values , annotationValue ) ; } } return value ; } | Do resolve . |
21,115 | protected BindingResult < T > doConvert ( Object value , ArgumentConversionContext < T > context ) { Optional < T > result = conversionService . convert ( value , context ) ; if ( result . isPresent ( ) && context . getArgument ( ) . getType ( ) == Optional . class ) { return ( ) -> ( Optional < T > ) result . get ( ) ; } return ( ) -> result ; } | Convert the value and return a binding result . |
21,116 | public static void with ( HttpRequest request , Runnable runnable ) { HttpRequest existing = REQUEST . get ( ) ; boolean isSet = false ; try { if ( request != existing ) { isSet = true ; REQUEST . set ( request ) ; } runnable . run ( ) ; } finally { if ( isSet ) { REQUEST . remove ( ) ; } } } | Wrap the execution of the given runnable in request context processing . |
21,117 | @ SuppressWarnings ( "unchecked" ) public static < T > Optional < HttpRequest < T > > currentRequest ( ) { return Optional . ofNullable ( REQUEST . get ( ) ) ; } | Retrieve the current server request context . |
21,118 | public void addShutdownHook ( ) { shutdownHookThread = new Thread ( new Runnable ( ) { public void run ( ) { beforeShutdown ( ) ; } } ) ; Runtime . getRuntime ( ) . addShutdownHook ( shutdownHookThread ) ; } | Add a shutdown hook . |
21,119 | public void reinitialize ( InputStream systemIn , PrintStream systemOut , PrintStream systemErr ) throws IOException { if ( reader != null ) { reader . shutdown ( ) ; } initialize ( systemIn , systemOut , systemErr ) ; } | Use in testing when System . out System . err or System . in change . |
21,120 | protected ConsoleReader createConsoleReader ( InputStream systemIn ) throws IOException { final PrintStream nullOutput = new PrintStream ( new ByteArrayOutputStream ( ) ) ; final PrintStream originalOut = Log . getOutput ( ) ; try { Log . setOutput ( nullOutput ) ; ConsoleReader consoleReader = new ConsoleReader ( systemIn , out ) ; consoleReader . setExpandEvents ( false ) ; return consoleReader ; } finally { Log . setOutput ( originalOut ) ; } } | Create a console reader . |
21,121 | protected Terminal createTerminal ( ) { terminal = TerminalFactory . create ( ) ; if ( isWindows ( ) ) { terminal . setEchoEnabled ( true ) ; } return terminal ; } | Creates the instance of Terminal used directly in MicronautConsole . Note that there is also another terminal instance created implicitly inside of ConsoleReader . That instance is controlled by the jline . terminal system property . |
21,122 | public void resetCompleters ( ) { final ConsoleReader reader = getReader ( ) ; if ( reader != null ) { Collection < Completer > completers = reader . getCompleters ( ) ; for ( Completer completer : completers ) { reader . removeCompleter ( completer ) ; } completers = reader . getCompleters ( ) ; for ( Completer completer : completers ) { reader . removeCompleter ( completer ) ; } } } | Reset the completers . |
21,123 | protected History prepareHistory ( ) throws IOException { File file = new File ( System . getProperty ( "user.home" ) , HISTORYFILE ) ; if ( ! file . exists ( ) ) { try { file . createNewFile ( ) ; } catch ( IOException ignored ) { } } return file . canWrite ( ) ? new FileHistory ( file ) : null ; } | Prepares a history file to be used by the ConsoleReader . This file will live in the home directory of the user . |
21,124 | public static synchronized void removeInstance ( ) { if ( instance != null ) { instance . removeShutdownHook ( ) ; instance . restoreOriginalSystemOutAndErr ( ) ; if ( instance . getReader ( ) != null ) { instance . getReader ( ) . shutdown ( ) ; } instance = null ; } } | Remove the Micronaut console . |
21,125 | protected void restoreTerminal ( ) { try { terminal . restore ( ) ; } catch ( Exception e ) { } if ( terminal instanceof UnixTerminal ) { try { new TerminalLineSettings ( ) . set ( "sane" ) ; } catch ( Exception e ) { } } } | Restore the terminal . |
21,126 | protected void redirectSystemOutAndErr ( boolean force ) { if ( force || ! ( System . out instanceof ConsolePrintStream ) ) { System . setOut ( new ConsolePrintStream ( out ) ) ; } if ( force || ! ( System . err instanceof ConsoleErrorPrintStream ) ) { System . setErr ( new ConsoleErrorPrintStream ( err ) ) ; } } | Redirect system out and error to the console . |
21,127 | public void indicateProgress ( ) { verifySystemOut ( ) ; progressIndicatorActive = true ; if ( isAnsiEnabled ( ) ) { if ( lastMessage != null && lastMessage . length ( ) > 0 ) { if ( ! lastMessage . contains ( maxIndicatorString ) ) { updateStatus ( lastMessage + indicator ) ; } } } else { out . print ( indicator ) ; } } | Indicates progress with the default progress indicator . |
21,128 | public void indicateProgress ( int number , int total ) { progressIndicatorActive = true ; String currMsg = lastMessage ; try { updateStatus ( currMsg + ' ' + number + " of " + total ) ; } finally { lastMessage = currMsg ; } } | Indicate progress for a number and total . |
21,129 | @ SuppressWarnings ( "MagicNumber" ) public void indicateProgressPercentage ( long number , long total ) { verifySystemOut ( ) ; progressIndicatorActive = true ; String currMsg = lastMessage ; try { int percentage = Math . round ( NumberMath . multiply ( NumberMath . divide ( number , total ) , 100 ) . floatValue ( ) ) ; if ( ! isAnsiEnabled ( ) ) { out . print ( ".." ) ; out . print ( percentage + '%' ) ; } else { updateStatus ( currMsg + ' ' + percentage + '%' ) ; } } finally { lastMessage = currMsg ; } } | Indicates progress as a percentage for the given number and total . |
21,130 | public void indicateProgress ( int number ) { verifySystemOut ( ) ; progressIndicatorActive = true ; String currMsg = lastMessage ; try { if ( isAnsiEnabled ( ) ) { updateStatus ( currMsg + ' ' + number ) ; } else { out . print ( ".." ) ; out . print ( number ) ; } } finally { lastMessage = currMsg ; } } | Indicates progress by number . |
21,131 | public void error ( String msg , Throwable error ) { try { if ( ( verbose || stacktrace ) && error != null ) { printStackTrace ( msg , error ) ; error ( ERROR , msg ) ; } else { error ( ERROR , msg + STACKTRACE_MESSAGE ) ; } } finally { postPrintMessage ( ) ; } } | Use to log an error . |
21,132 | public void log ( String msg ) { verifySystemOut ( ) ; PrintStream printStream = out ; try { if ( userInputActive ) { erasePrompt ( printStream ) ; } if ( msg . endsWith ( LINE_SEPARATOR ) ) { printStream . print ( msg ) ; } else { printStream . println ( msg ) ; } cursorMove = 0 ; } finally { printStream . flush ( ) ; postPrintMessage ( ) ; } } | Logs a message below the current status message . |
21,133 | public void append ( String msg ) { verifySystemOut ( ) ; PrintStream printStream = out ; try { if ( userInputActive && ! appendCalled ) { printStream . print ( moveDownToSkipPrompt ( ) ) ; appendCalled = true ; } if ( msg . endsWith ( LINE_SEPARATOR ) ) { printStream . print ( msg ) ; } else { printStream . println ( msg ) ; } cursorMove = 0 ; } finally { progressIndicatorActive = false ; } } | Append a message . |
21,134 | private Publisher < GetParametersByPathResult > getHierarchy ( String path ) { GetParametersByPathRequest getRequest = new GetParametersByPathRequest ( ) . withWithDecryption ( awsParameterStoreConfiguration . getUseSecureParameters ( ) ) . withPath ( path ) . withRecursive ( true ) ; Future < GetParametersByPathResult > future = client . getParametersByPathAsync ( getRequest ) ; Flowable < GetParametersByPathResult > invokeFlowable = Flowable . fromFuture ( future , Schedulers . io ( ) ) ; invokeFlowable = invokeFlowable . onErrorResumeNext ( AWSParameterStoreConfigClient :: onGetParametersByPathResult ) ; return invokeFlowable ; } | Gets the Parameter hierarchy from AWS parameter store . Please note this only returns something if the current node has children and will not return itself . |
21,135 | private Publisher < GetParametersResult > getParameters ( String path ) { GetParametersRequest getRequest = new GetParametersRequest ( ) . withWithDecryption ( awsParameterStoreConfiguration . getUseSecureParameters ( ) ) . withNames ( path ) ; Future < GetParametersResult > future = client . getParametersAsync ( getRequest ) ; Flowable < GetParametersResult > invokeFlowable = Flowable . fromFuture ( future , Schedulers . io ( ) ) ; invokeFlowable = invokeFlowable . onErrorResumeNext ( AWSParameterStoreConfigClient :: onGetParametersError ) ; return invokeFlowable ; } | Gets the parameters from AWS . |
21,136 | private Set < String > calcPropertySourceNames ( String prefix , Set < String > activeNames ) { return ClientUtil . calcPropertySourceNames ( prefix , activeNames , "_" ) ; } | Calculates property names to look for . |
21,137 | private Map < String , Object > convertParametersToMap ( ParametersWithBasePath parametersWithBasePath ) { Map < String , Object > output = new HashMap < > ( ) ; for ( Parameter param : parametersWithBasePath . parameters ) { switch ( param . getType ( ) ) { case "StringList" : String [ ] items = param . getValue ( ) . split ( "," ) ; for ( String item : items ) { String [ ] keyValue = item . split ( "=" ) ; if ( keyValue . length > 1 ) { output . put ( keyValue [ 0 ] , keyValue [ 1 ] ) ; } else { addKeyFromPath ( output , parametersWithBasePath , param , keyValue [ 0 ] ) ; } } break ; case "SecureString" : String [ ] keyValue = param . getValue ( ) . split ( "=" ) ; if ( keyValue . length > 1 ) { output . put ( keyValue [ 0 ] , keyValue [ 1 ] ) ; } else { addKeyFromPath ( output , parametersWithBasePath , param , keyValue [ 0 ] ) ; } break ; default : case "String" : String [ ] keyVal = param . getValue ( ) . split ( "=" ) ; if ( keyVal . length > 1 ) { output . put ( keyVal [ 0 ] , keyVal [ 1 ] ) ; } else { addKeyFromPath ( output , parametersWithBasePath , param , keyVal [ 0 ] ) ; } break ; } } return output ; } | Helper class for converting parameters from amazon format to a map . |
21,138 | @ SuppressWarnings ( "unchecked" ) private List < PropertyDescriptor > introspectProperties ( Method [ ] methodDescriptors ) { if ( methodDescriptors == null ) { return null ; } HashMap < String , HashMap > propertyTable = new HashMap < > ( methodDescriptors . length ) ; for ( Method methodDescriptor : methodDescriptors ) { introspectGet ( methodDescriptor , propertyTable ) ; introspectSet ( methodDescriptor , propertyTable ) ; } fixGetSet ( propertyTable ) ; ArrayList < PropertyDescriptor > propertyList = new ArrayList < > ( ) ; for ( Map . Entry < String , HashMap > entry : propertyTable . entrySet ( ) ) { String propertyName = entry . getKey ( ) ; HashMap table = entry . getValue ( ) ; if ( table == null ) { continue ; } String normalTag = ( String ) table . get ( STR_NORMAL ) ; if ( ( normalTag == null ) ) { continue ; } Method get = ( Method ) table . get ( STR_NORMAL + PREFIX_GET ) ; Method set = ( Method ) table . get ( STR_NORMAL + PREFIX_SET ) ; PropertyDescriptor propertyDesc = new PropertyDescriptor ( propertyName , get , set ) ; propertyList . add ( propertyDesc ) ; } return Collections . unmodifiableList ( propertyList ) ; } | Introspects the supplied class and returns a list of the Properties of the class . |
21,139 | public static < T > Publisher < T > onComplete ( Publisher < T > publisher , Supplier < CompletableFuture < Void > > future ) { return actual -> publisher . subscribe ( new CompletionAwareSubscriber < T > ( ) { protected void doOnSubscribe ( Subscription subscription ) { actual . onSubscribe ( subscription ) ; } protected void doOnNext ( T message ) { try { actual . onNext ( message ) ; } catch ( Throwable e ) { onError ( e ) ; } } protected void doOnError ( Throwable t ) { actual . onError ( t ) ; } protected void doOnComplete ( ) { future . get ( ) . whenComplete ( ( aVoid , throwable ) -> { if ( throwable != null ) { actual . onError ( throwable ) ; } else { actual . onComplete ( ) ; } } ) ; } } ) ; } | Allow executing logic on completion of a Publisher . |
21,140 | public static boolean isConvertibleToPublisher ( Class < ? > type ) { if ( Publisher . class . isAssignableFrom ( type ) ) { return true ; } else { for ( Class < ? > reactiveType : REACTIVE_TYPES ) { if ( reactiveType . isAssignableFrom ( type ) ) { return true ; } } return false ; } } | Is the given type a Publisher or convertible to a publisher . |
21,141 | public static boolean isConvertibleToPublisher ( Object object ) { if ( object == null ) { return false ; } if ( object instanceof Publisher ) { return true ; } else { return isConvertibleToPublisher ( object . getClass ( ) ) ; } } | Is the given object a Publisher or convertible to a publisher . |
21,142 | public static < T > T convertPublisher ( Object object , Class < T > publisherType ) { Objects . requireNonNull ( object , "Invalid argument [object]: " + object ) ; Objects . requireNonNull ( object , "Invalid argument [publisherType]: " + publisherType ) ; if ( object instanceof CompletableFuture ) { @ SuppressWarnings ( "unchecked" ) Publisher < T > futurePublisher = ( Publisher < T > ) Publishers . fromCompletableFuture ( ( ) -> ( ( CompletableFuture ) object ) ) ; return ConversionService . SHARED . convert ( futurePublisher , publisherType ) . orElseThrow ( ( ) -> new IllegalArgumentException ( "Unsupported Reactive type: " + object . getClass ( ) ) ) ; } else { return ConversionService . SHARED . convert ( object , publisherType ) . orElseThrow ( ( ) -> new IllegalArgumentException ( "Unsupported Reactive type: " + object . getClass ( ) ) ) ; } } | Attempts to convert the publisher to the given type . |
21,143 | public static boolean isSingle ( Class < ? > type ) { for ( Class < ? > reactiveType : SINGLE_TYPES ) { if ( reactiveType . isAssignableFrom ( type ) ) { return true ; } } return false ; } | Does the given reactive type emit a single result . |
21,144 | protected final void addAnnotationValuesFromData ( List results , Map < CharSequence , Object > values ) { if ( values != null ) { Object v = values . get ( AnnotationMetadata . VALUE_MEMBER ) ; if ( v instanceof io . micronaut . core . annotation . AnnotationValue [ ] ) { io . micronaut . core . annotation . AnnotationValue [ ] avs = ( io . micronaut . core . annotation . AnnotationValue [ ] ) v ; for ( io . micronaut . core . annotation . AnnotationValue av : avs ) { addValuesToResults ( results , av ) ; } } else if ( v instanceof Collection ) { Collection c = ( Collection ) v ; for ( Object o : c ) { if ( o instanceof io . micronaut . core . annotation . AnnotationValue ) { addValuesToResults ( results , ( ( io . micronaut . core . annotation . AnnotationValue ) o ) ) ; } } } } } | Adds any annotation values found in the values map to the results . |
21,145 | protected void addValuesToResults ( List < io . micronaut . core . annotation . AnnotationValue > results , io . micronaut . core . annotation . AnnotationValue values ) { results . add ( values ) ; } | Adds a values instance to the results . |
21,146 | public Optional < URL > resolve ( String resourcePath ) { for ( Map . Entry < String , List < ResourceLoader > > entry : resourceMappings . entrySet ( ) ) { List < ResourceLoader > loaders = entry . getValue ( ) ; String mapping = entry . getKey ( ) ; if ( ! loaders . isEmpty ( ) && pathMatcher . matches ( mapping , resourcePath ) ) { String path = pathMatcher . extractPathWithinPattern ( mapping , resourcePath ) ; if ( StringUtils . isEmpty ( path ) ) { path = INDEX_PAGE ; } if ( path . startsWith ( "/" ) ) { path = path . substring ( 1 ) ; } for ( ResourceLoader loader : loaders ) { Optional < URL > resource = loader . getResource ( path ) ; if ( resource . isPresent ( ) ) { return resource ; } else { if ( path . indexOf ( '.' ) == - 1 ) { if ( ! path . endsWith ( "/" ) ) { path = path + "/" ; } path += INDEX_PAGE ; resource = loader . getResource ( path ) ; if ( resource . isPresent ( ) ) { return resource ; } } } } } } return Optional . empty ( ) ; } | Resolves a path to a URL . |
21,147 | private String resolveTemplate ( AnnotationValue < Client > clientAnnotation , String templateString ) { String path = clientAnnotation . get ( "path" , String . class ) . orElse ( null ) ; if ( StringUtils . isNotEmpty ( path ) ) { return path + templateString ; } else { String value = clientAnnotation . getValue ( String . class ) . orElse ( null ) ; if ( StringUtils . isNotEmpty ( value ) ) { if ( value . startsWith ( "/" ) ) { return value + templateString ; } } return templateString ; } } | Resolve the template for the client annotation . |
21,148 | void addGenericTypes ( String paramName , Map < String , Object > generics ) { genericTypes . put ( paramName , generics ) ; } | Adds generics info for the given parameter name . |
21,149 | public static int countOccurrencesOf ( String str , String sub ) { if ( str == null || sub == null || str . length ( ) == 0 || sub . length ( ) == 0 ) { return 0 ; } int count = 0 ; int pos = 0 ; int idx ; while ( ( idx = str . indexOf ( sub , pos ) ) != - 1 ) { ++ count ; pos = idx + sub . length ( ) ; } return count ; } | Count the occurrences of the substring in string s . |
21,150 | public void visitBeanDefinitionConstructor ( AnnotationMetadata annotationMetadata , boolean requiresReflection , Map < String , Object > argumentTypes , Map < String , AnnotationMetadata > argumentAnnotationMetadata , Map < String , Map < String , Object > > genericTypes ) { if ( constructorVisitor == null ) { visitBeanDefinitionConstructorInternal ( annotationMetadata , requiresReflection , argumentTypes , argumentAnnotationMetadata , genericTypes ) ; visitBuildMethodDefinition ( annotationMetadata , argumentTypes , argumentAnnotationMetadata ) ; visitInjectMethodDefinition ( ) ; } } | Visits the constructor used to create the bean definition . |
21,151 | public void visitBeanDefinitionConstructor ( AnnotationMetadata annotationMetadata , boolean requiresReflection ) { if ( constructorVisitor == null ) { visitBeanDefinitionConstructorInternal ( annotationMetadata , requiresReflection , Collections . emptyMap ( ) , null , null ) ; visitBuildMethodDefinition ( annotationMetadata , Collections . emptyMap ( ) , Collections . emptyMap ( ) ) ; visitInjectMethodDefinition ( ) ; } } | Visits a no - args constructor used to create the bean definition . |
21,152 | @ SuppressWarnings ( "Duplicates" ) public void visitBeanDefinitionEnd ( ) { if ( classWriter == null ) { throw new IllegalStateException ( "At least one called to visitBeanDefinitionConstructor(..) is required" ) ; } String [ ] interfaceInternalNames = new String [ interfaceTypes . size ( ) ] ; Iterator < Class > j = interfaceTypes . iterator ( ) ; for ( int i = 0 ; i < interfaceInternalNames . length ; i ++ ) { interfaceInternalNames [ i ] = Type . getInternalName ( j . next ( ) ) ; } classWriter . visit ( V1_8 , ACC_SYNTHETIC , beanDefinitionInternalName , generateBeanDefSig ( providedType . getInternalName ( ) ) , isSuperFactory ? TYPE_ABSTRACT_BEAN_DEFINITION . getInternalName ( ) : superType . getInternalName ( ) , interfaceInternalNames ) ; if ( buildMethodVisitor == null ) { throw new IllegalStateException ( "At least one call to visitBeanDefinitionConstructor() is required" ) ; } finalizeInjectMethod ( ) ; finalizeBuildMethod ( ) ; finalizeAnnotationMetadata ( ) ; finalizeTypeArguments ( ) ; if ( preprocessMethods ) { GeneratorAdapter requiresMethodProcessing = startPublicMethod ( classWriter , "requiresMethodProcessing" , boolean . class . getName ( ) ) ; requiresMethodProcessing . push ( true ) ; requiresMethodProcessing . visitInsn ( IRETURN ) ; requiresMethodProcessing . visitMaxs ( 1 , 1 ) ; requiresMethodProcessing . visitEnd ( ) ; } constructorVisitor . visitInsn ( RETURN ) ; constructorVisitor . visitMaxs ( DEFAULT_MAX_STACK , 1 ) ; if ( buildMethodVisitor != null ) { buildMethodVisitor . visitInsn ( ARETURN ) ; buildMethodVisitor . visitMaxs ( DEFAULT_MAX_STACK , buildMethodLocalCount ) ; } if ( injectMethodVisitor != null ) { injectMethodVisitor . visitMaxs ( DEFAULT_MAX_STACK , injectMethodLocalCount ) ; } if ( postConstructMethodVisitor != null ) { postConstructMethodVisitor . visitVarInsn ( ALOAD , postConstructInstanceIndex ) ; postConstructMethodVisitor . visitInsn ( ARETURN ) ; postConstructMethodVisitor . visitMaxs ( DEFAULT_MAX_STACK , postConstructMethodLocalCount ) ; } if ( preDestroyMethodVisitor != null ) { preDestroyMethodVisitor . visitVarInsn ( ALOAD , preDestroyInstanceIndex ) ; preDestroyMethodVisitor . visitInsn ( ARETURN ) ; preDestroyMethodVisitor . visitMaxs ( DEFAULT_MAX_STACK , preDestroyMethodLocalCount ) ; } for ( GeneratorAdapter method : loadTypeMethods . values ( ) ) { method . visitMaxs ( 3 , 1 ) ; method . visitEnd ( ) ; } classWriter . visitEnd ( ) ; this . beanFinalized = true ; } | Finalize the bean definition to the given output stream . |
21,153 | public void setSearchLocation ( String searchLocation ) { ResourceLoader resourceLoader = getDefaultResourceLoader ( ) ; patchMatchingResolver = new PathMatchingResourcePatternResolver ( resourceLoader ) ; initializeForSearchLocation ( searchLocation ) ; } | Set the search location . |
21,154 | public void setSearchLocations ( Collection < String > searchLocations ) { patchMatchingResolver = new PathMatchingResourcePatternResolver ( getDefaultResourceLoader ( ) ) ; for ( String searchLocation : searchLocations ) { initializeForSearchLocation ( searchLocation ) ; } } | Set search locations . |
21,155 | public Resource findResourceForClassName ( String className ) { if ( className . contains ( CLOSURE_MARKER ) ) { className = className . substring ( 0 , className . indexOf ( CLOSURE_MARKER ) ) ; } Resource resource = classNameToResourceCache . get ( className ) ; if ( resource == null ) { String classNameWithPathSeparator = className . replace ( "." , FILE_SEPARATOR ) ; for ( String pathPattern : getSearchPatternForExtension ( classNameWithPathSeparator , ".groovy" , ".java" , ".kt" ) ) { resource = resolveExceptionSafe ( pathPattern ) ; if ( resource != null && resource . exists ( ) ) { classNameToResourceCache . put ( className , resource ) ; break ; } } } return resource != null && resource . exists ( ) ? resource : null ; } | Find a resource for class name . |
21,156 | public AbstractConfigurableTemplateResolver templateResolver ( ViewsConfiguration viewsConfiguration , ThymeleafViewsRendererConfiguration rendererConfiguration ) { ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver ( ) ; templateResolver . setPrefix ( viewsConfiguration . getFolder ( ) ) ; templateResolver . setCharacterEncoding ( rendererConfiguration . getCharacterEncoding ( ) ) ; templateResolver . setTemplateMode ( rendererConfiguration . getTemplateMode ( ) ) ; templateResolver . setSuffix ( rendererConfiguration . getSuffix ( ) ) ; templateResolver . setForceSuffix ( rendererConfiguration . getForceSuffix ( ) ) ; templateResolver . setForceTemplateMode ( rendererConfiguration . getForceTemplateMode ( ) ) ; templateResolver . setCacheTTLMs ( rendererConfiguration . getCacheTTLMs ( ) ) ; templateResolver . setCheckExistence ( rendererConfiguration . getCheckExistence ( ) ) ; templateResolver . setCacheable ( rendererConfiguration . getCacheable ( ) ) ; return templateResolver ; } | Constructs the template resolver bean . |
21,157 | public TemplateEngine templateEngine ( ITemplateResolver templateResolver , IEngineContextFactory engineContextFactory , ILinkBuilder linkBuilder ) { TemplateEngine engine = new TemplateEngine ( ) ; engine . setEngineContextFactory ( engineContextFactory ) ; engine . setLinkBuilder ( linkBuilder ) ; engine . setTemplateResolver ( templateResolver ) ; return engine ; } | Constructs the template engine . |
21,158 | @ SuppressWarnings ( "unchecked" ) void init ( BeanContext beanContext , ThreadFactory threadFactory ) { try { BeanDefinition < ExecutorService > beanDefinition = beanContext . getBeanDefinition ( ExecutorService . class , Qualifiers . byName ( TaskExecutors . SCHEDULED ) ) ; Collection < BeanCreatedEventListener > schedulerCreateListeners = beanContext . getBeansOfType ( BeanCreatedEventListener . class , Qualifiers . byTypeArguments ( ScheduledExecutorService . class ) ) ; Schedulers . addExecutorServiceDecorator ( Environment . MICRONAUT , ( scheduler , scheduledExecutorService ) -> { for ( BeanCreatedEventListener schedulerCreateListener : schedulerCreateListeners ) { Object newBean = schedulerCreateListener . onCreated ( new BeanCreatedEvent ( beanContext , beanDefinition , BeanIdentifier . of ( "reactor-" + scheduler . getClass ( ) . getSimpleName ( ) ) , scheduledExecutorService ) ) ; if ( ! ( newBean instanceof ScheduledExecutorService ) ) { throw new BeanContextException ( "Bean creation listener [" + schedulerCreateListener + "] should return ScheduledExecutorService, but returned " + newBean ) ; } scheduledExecutorService = ( ScheduledExecutorService ) newBean ; } return scheduledExecutorService ; } ) ; } catch ( Exception e ) { if ( LOG . isErrorEnabled ( ) ) { LOG . error ( "Could not instrument Reactor for Tracing: " + e . getMessage ( ) , e ) ; } } } | Initialize instrumentation for reactor with the tracer and factory . |
21,159 | protected boolean hasStereotype ( Element element , Class < ? extends Annotation > stereotype ) { return hasStereotype ( element , stereotype . getName ( ) ) ; } | Return whether the given element is annotated with the given annotation stereotype . |
21,160 | protected boolean hasStereotype ( Element element , String ... stereotypes ) { return hasStereotype ( element , Arrays . asList ( stereotypes ) ) ; } | Return whether the given element is annotated with the given annotation stereotypes . |
21,161 | protected boolean hasStereotype ( Element element , List < String > stereotypes ) { if ( element == null ) { return false ; } if ( stereotypes . contains ( element . toString ( ) ) ) { return true ; } AnnotationMetadata annotationMetadata = getAnnotationMetadata ( element ) ; for ( String stereotype : stereotypes ) { if ( annotationMetadata . hasStereotype ( stereotype ) ) { return true ; } } return false ; } | Return whether the given element is annotated with any of the given annotation stereotypes . |
21,162 | public boolean isAnnotated ( ExecutableElement method ) { List < ? extends AnnotationMirror > annotationMirrors = method . getAnnotationMirrors ( ) ; for ( AnnotationMirror annotationMirror : annotationMirrors ) { String typeName = annotationMirror . getAnnotationType ( ) . toString ( ) ; if ( ! AnnotationUtil . INTERNAL_ANNOTATION_NAMES . contains ( typeName ) ) { return true ; } } return false ; } | Check whether the method is annotated . |
21,163 | private Flowable < List < ServiceInstance > > convertInstancesResulttoServiceInstances ( ListInstancesResult instancesResult ) { List < ServiceInstance > serviceInstances = new ArrayList < > ( ) ; for ( InstanceSummary instanceSummary : instancesResult . getInstances ( ) ) { try { String uri = "http://" + instanceSummary . getAttributes ( ) . get ( "URI" ) ; ServiceInstance serviceInstance = new EC2ServiceInstance ( instanceSummary . getId ( ) , new URI ( uri ) ) . metadata ( instanceSummary . getAttributes ( ) ) . build ( ) ; serviceInstances . add ( serviceInstance ) ; } catch ( URISyntaxException e ) { return Flowable . error ( e ) ; } } return Flowable . just ( serviceInstances ) ; } | transforms an aws result into a list of service instances . |
21,164 | public Publisher < List < ServiceInstance > > getInstances ( String serviceId ) { if ( serviceId == null ) { serviceId = getRoute53ClientDiscoveryConfiguration ( ) . getAwsServiceId ( ) ; } ListInstancesRequest instancesRequest = new ListInstancesRequest ( ) . withServiceId ( serviceId ) ; Future < ListInstancesResult > instanceResult = getDiscoveryClient ( ) . listInstancesAsync ( instancesRequest ) ; Flowable < ListInstancesResult > observableInstanceResult = Flowable . fromFuture ( instanceResult ) ; return observableInstanceResult . flatMap ( this :: convertInstancesResulttoServiceInstances ) ; } | Gets a list of instances registered with Route53 given a service ID . |
21,165 | public Publisher < List < String > > getServiceIds ( ) { ServiceFilter serviceFilter = new ServiceFilter ( ) . withName ( "NAMESPACE_ID" ) . withValues ( getRoute53ClientDiscoveryConfiguration ( ) . getNamespaceId ( ) ) ; ListServicesRequest listServicesRequest = new ListServicesRequest ( ) . withFilters ( serviceFilter ) ; Future < ListServicesResult > response = getDiscoveryClient ( ) . listServicesAsync ( listServicesRequest ) ; Flowable < ListServicesResult > flowableList = Flowable . fromFuture ( response ) ; return flowableList . flatMap ( this :: convertServiceIds ) ; } | Gets a list of service IDs from AWS for a given namespace . |
21,166 | private Publisher < List < String > > convertServiceIds ( ListServicesResult listServicesResult ) { List < ServiceSummary > services = listServicesResult . getServices ( ) ; List < String > serviceIds = new ArrayList < > ( ) ; for ( ServiceSummary service : services ) { serviceIds . add ( service . getId ( ) ) ; } return Publishers . just ( serviceIds ) ; } | Converts the services IDs returned for usage in MN . |
21,167 | public void run ( ) { while ( ! registered ) { GetOperationRequest operationRequest = new GetOperationRequest ( ) . withOperationId ( operationId ) ; GetOperationResult result = discoveryClient . getOperation ( operationRequest ) ; if ( LOG . isInfoEnabled ( ) ) { LOG . info ( "Service registration for operation " + operationId + " resulted in " + result . getOperation ( ) . getStatus ( ) ) ; } if ( result . getOperation ( ) . getStatus ( ) . equalsIgnoreCase ( "failure" ) || result . getOperation ( ) . getStatus ( ) . equalsIgnoreCase ( "success" ) ) { registered = true ; if ( result . getOperation ( ) . getStatus ( ) . equalsIgnoreCase ( "failure" ) ) { if ( route53AutoRegistrationConfiguration . isFailFast ( ) && embeddedServerInstance instanceof EmbeddedServerInstance ) { if ( LOG . isErrorEnabled ( ) ) { LOG . error ( "Error registering instance shutting down instance because failfast is set." ) ; } ( ( EmbeddedServerInstance ) embeddedServerInstance ) . getEmbeddedServer ( ) . stop ( ) ; } } } } try { Thread . currentThread ( ) . sleep ( 5000 ) ; } catch ( InterruptedException e ) { if ( LOG . isErrorEnabled ( ) ) { LOG . error ( "Registration monitor service has been aborted, unable to verify proper service registration on Route 53." , e ) ; } } } | Runs the polling process to AWS checks every 5 seconds . |
21,168 | private static Set < String > getEC2DiscoveryUrlsFromZone ( String dnsName , DiscoveryUrlType type ) { Set < String > eipsForZone ; try { dnsName = "txt." + dnsName ; LOG . debug ( "The zone url to be looked up is {} :" , dnsName ) ; Set < String > ec2UrlsForZone = DnsResolver . getCNamesFromTxtRecord ( dnsName ) ; for ( String ec2Url : ec2UrlsForZone ) { LOG . debug ( "The eureka url for the dns name {} is {}" , dnsName , ec2Url ) ; ec2UrlsForZone . add ( ec2Url ) ; } if ( DiscoveryUrlType . CNAME . equals ( type ) ) { return ec2UrlsForZone ; } eipsForZone = new TreeSet < > ( ) ; for ( String cname : ec2UrlsForZone ) { String [ ] tokens = cname . split ( "\\." ) ; String ec2HostName = tokens [ 0 ] ; String [ ] ips = ec2HostName . split ( "-" ) ; StringBuilder eipBuffer = new StringBuilder ( ) ; for ( int ipCtr = 1 ; ipCtr < 5 ; ipCtr ++ ) { eipBuffer . append ( ips [ ipCtr ] ) ; if ( ipCtr < 4 ) { eipBuffer . append ( "." ) ; } } eipsForZone . add ( eipBuffer . toString ( ) ) ; } LOG . debug ( "The EIPS for {} is {} :" , dnsName , eipsForZone ) ; } catch ( Throwable e ) { throw new RuntimeException ( "Cannot get cnames bound to the region:" + dnsName , e ) ; } return eipsForZone ; } | Get the list of EC2 URLs given the zone name . |
21,169 | public Optional < InputStream > getResourceAsStream ( String path ) { if ( ! isDirectory ( path ) ) { return Optional . ofNullable ( classLoader . getResourceAsStream ( prefixPath ( path ) ) ) ; } return Optional . empty ( ) ; } | Obtains a resource as a stream . |
21,170 | public Optional < URL > getResource ( String path ) { boolean isDirectory = isDirectory ( path ) ; if ( ! isDirectory ) { URL url = classLoader . getResource ( prefixPath ( path ) ) ; return Optional . ofNullable ( url ) ; } return Optional . empty ( ) ; } | Obtains a resource URL . |
21,171 | public Stream < URL > getResources ( String path ) { Enumeration < URL > all ; try { all = classLoader . getResources ( prefixPath ( path ) ) ; } catch ( IOException e ) { return Stream . empty ( ) ; } Stream . Builder < URL > builder = Stream . builder ( ) ; while ( all . hasMoreElements ( ) ) { URL url = all . nextElement ( ) ; builder . accept ( url ) ; } return builder . build ( ) ; } | Obtains a stream of resource URLs . |
21,172 | String simpleBinaryNameFor ( TypeElement typeElement ) { Name elementBinaryName = elementUtils . getBinaryName ( typeElement ) ; PackageElement packageElement = elementUtils . getPackageOf ( typeElement ) ; String packageName = packageElement . getQualifiedName ( ) . toString ( ) ; return elementBinaryName . toString ( ) . replaceFirst ( packageName + "\\." , "" ) ; } | The binary name of the type as a String . |
21,173 | String getterNameFor ( Element field ) { String methodNamePrefix = "get" ; if ( field . asType ( ) . getKind ( ) == TypeKind . BOOLEAN ) { methodNamePrefix = "is" ; } return methodNamePrefix + NameUtils . capitalize ( field . getSimpleName ( ) . toString ( ) ) ; } | The name of a getter for the given field . |
21,174 | public ExecutableElement concreteConstructorFor ( TypeElement classElement , AnnotationUtils annotationUtils ) { List < ExecutableElement > constructors = findNonPrivateConstructors ( classElement ) ; if ( constructors . isEmpty ( ) ) { return null ; } if ( constructors . size ( ) == 1 ) { return constructors . get ( 0 ) ; } Optional < ExecutableElement > element = constructors . stream ( ) . filter ( ctor -> { final AnnotationMetadata annotationMetadata = annotationUtils . getAnnotationMetadata ( ctor ) ; return annotationMetadata . hasStereotype ( Inject . class ) || annotationMetadata . hasStereotype ( Creator . class ) ; } ) . findFirst ( ) ; if ( ! element . isPresent ( ) ) { element = constructors . stream ( ) . filter ( ctor -> ctor . getModifiers ( ) . contains ( PUBLIC ) ) . findFirst ( ) ; } return element . orElse ( null ) ; } | The constructor inject for the given class element . |
21,175 | Optional < ExecutableElement > findAccessibleNoArgumentInstanceMethod ( TypeElement classElement , String methodName ) { return ElementFilter . methodsIn ( elementUtils . getAllMembers ( classElement ) ) . stream ( ) . filter ( m -> m . getSimpleName ( ) . toString ( ) . equals ( methodName ) && ! isPrivate ( m ) && ! isStatic ( m ) ) . findFirst ( ) ; } | Finds a no argument method of the given name . |
21,176 | Class < ? > classOfPrimitiveFor ( String primitiveType ) { return ClassUtils . getPrimitiveType ( primitiveType ) . orElseThrow ( ( ) -> new IllegalArgumentException ( "Unknown primitive type: " + primitiveType ) ) ; } | Obtains the class for a given primitive type name . |
21,177 | Class < ? > classOfPrimitiveArrayFor ( String primitiveType ) { return ClassUtils . arrayTypeForPrimitive ( primitiveType ) . orElseThrow ( ( ) -> new IllegalArgumentException ( "Unsupported primitive type " + primitiveType ) ) ; } | Obtains the class for the given primitive type array . |
21,178 | TypeElement superClassFor ( TypeElement element ) { TypeMirror superclass = element . getSuperclass ( ) ; if ( superclass . getKind ( ) == TypeKind . NONE ) { return null ; } DeclaredType kind = ( DeclaredType ) superclass ; return ( TypeElement ) kind . asElement ( ) ; } | Obtains the super type element for a given type element . |
21,179 | String resolveTypeName ( TypeMirror type ) { Object reference = resolveTypeReference ( type ) ; if ( reference instanceof Class ) { return ( ( Class ) reference ) . getName ( ) ; } return reference . toString ( ) ; } | Resolves a type name for the given name . |
21,180 | boolean isPackagePrivate ( Element element ) { Set < Modifier > modifiers = element . getModifiers ( ) ; return ! ( modifiers . contains ( PUBLIC ) || modifiers . contains ( PROTECTED ) || modifiers . contains ( PRIVATE ) ) ; } | Returns whether an element is package private . |
21,181 | boolean isInheritedAndNotPublic ( TypeElement concreteClass , TypeElement declaringClass , Element methodOrField ) { PackageElement packageOfDeclaringClass = elementUtils . getPackageOf ( declaringClass ) ; PackageElement packageOfConcreteClass = elementUtils . getPackageOf ( concreteClass ) ; return declaringClass != concreteClass && ! packageOfDeclaringClass . getQualifiedName ( ) . equals ( packageOfConcreteClass . getQualifiedName ( ) ) && ( isProtected ( methodOrField ) || ! isPublic ( methodOrField ) ) ; } | Return whether the given method or field is inherited but not public . |
21,182 | Optional < ExecutableElement > overridingOrHidingMethod ( ExecutableElement overridden , TypeElement classElement ) { List < ExecutableElement > methods = ElementFilter . methodsIn ( elementUtils . getAllMembers ( classElement ) ) ; for ( ExecutableElement method : methods ) { if ( ! method . equals ( overridden ) && method . getSimpleName ( ) . equals ( overridden . getSimpleName ( ) ) ) { return Optional . of ( method ) ; } } TypeElement superClass = superClassFor ( classElement ) ; if ( superClass != null && ! isObjectClass ( superClass ) ) { return overridingOrHidingMethod ( overridden , superClass ) ; } return Optional . empty ( ) ; } | Tests if candidate method is overridden from a given class or subclass . |
21,183 | boolean isOptional ( TypeMirror mirror ) { return typeUtils . erasure ( mirror ) . toString ( ) . equals ( Optional . class . getName ( ) ) ; } | Is the given type mirror an optional . |
21,184 | public void setDefaultZone ( List < URL > defaultZone ) { this . defaultZone = defaultZone . stream ( ) . map ( uriMapper ( ) ) . map ( uri -> ServiceInstance . builder ( getServiceID ( ) , uri ) . build ( ) ) . collect ( Collectors . toList ( ) ) ; } | Sets the Discovery servers to use for the default zone . |
21,185 | public void setZones ( Map < String , List < URL > > zones ) { if ( zones != null ) { this . otherZones = zones . entrySet ( ) . stream ( ) . flatMap ( ( Function < Map . Entry < String , List < URL > > , Stream < ServiceInstance > > ) entry -> entry . getValue ( ) . stream ( ) . map ( uriMapper ( ) ) . map ( uri -> ServiceInstance . builder ( getServiceID ( ) , uri ) . zone ( entry . getKey ( ) ) . build ( ) ) ) . collect ( Collectors . toList ( ) ) ; } } | Configures Discovery servers in other zones . |
21,186 | void setNettyHeaders ( io . netty . handler . codec . http . HttpHeaders headers ) { this . nettyHeaders = headers ; } | Sets the underlying netty headers . |
21,187 | protected boolean isAcceptable ( Element element ) { if ( element . getKind ( ) == ElementKind . METHOD ) { Set < Modifier > modifiers = element . getModifiers ( ) ; return modifiers . contains ( Modifier . PUBLIC ) && ! modifiers . contains ( Modifier . FINAL ) && ! modifiers . contains ( Modifier . STATIC ) ; } else { return false ; } } | Only accepts public non file or static methods . |
21,188 | private void processPostStartRequirements ( ConditionContext context , AnnotationValue < Requires > requirements ) { processPreStartRequirements ( context , requirements ) ; if ( context . isFailing ( ) ) { return ; } if ( ! matchesPresenceOfBeans ( context , requirements ) ) { return ; } if ( ! matchesAbsenceOfBeans ( context , requirements ) ) { return ; } matchesCustomConditions ( context , requirements ) ; } | This method will run conditions that require all beans to be loaded . These conditions included beans missingBeans and custom conditions . |
21,189 | public static < T > ArgumentCheck check ( String name , T value ) { return new ArgumentCheck < > ( name , value ) ; } | Perform a check on an argument . |
21,190 | @ SuppressWarnings ( "unchecked" ) protected final void setLinks ( Map < String , Object > links ) { for ( Map . Entry < String , Object > entry : links . entrySet ( ) ) { String name = entry . getKey ( ) ; Object value = entry . getValue ( ) ; if ( value instanceof Map ) { Map < String , Object > linkMap = ( Map < String , Object > ) value ; link ( name , linkMap ) ; } } } | Allows de - serializing of links with Jackson . |
21,191 | public AnnotationValueBuilder < T > member ( String name , long i ) { values . put ( name , i ) ; return this ; } | Sets the value member to the given long value . |
21,192 | public AnnotationValueBuilder < T > member ( String name , boolean bool ) { values . put ( name , bool ) ; return this ; } | Sets the value member to the given boolean value . |
21,193 | public static boolean isSetter ( String name , Class [ ] args ) { if ( StringUtils . isEmpty ( name ) || args == null ) { return false ; } if ( args . length != 1 ) { return false ; } return NameUtils . isSetterName ( name ) ; } | Is the method a setter . |
21,194 | public static Class getWrapperType ( Class primitiveType ) { if ( primitiveType . isPrimitive ( ) ) { return PRIMITIVES_TO_WRAPPERS . get ( primitiveType ) ; } return primitiveType ; } | Obtain the wrapper type for the given primitive . |
21,195 | public static Class getPrimitiveType ( Class wrapperType ) { Class < ? > wrapper = WRAPPER_TO_PRIMITIVE . get ( wrapperType ) ; if ( wrapper != null ) { return wrapper ; } return wrapperType ; } | Obtain the primitive type for the given wrapper type . |
21,196 | public static Optional < Method > getMethod ( Class type , String methodName , Class ... argTypes ) { try { return Optional . of ( type . getMethod ( methodName , argTypes ) ) ; } catch ( NoSuchMethodException e ) { return findMethod ( type , methodName , argTypes ) ; } } | Obtains a method . |
21,197 | public static < R , T > R invokeMethod ( T instance , Method method , Object ... arguments ) { try { return ( R ) method . invoke ( instance , arguments ) ; } catch ( IllegalAccessException e ) { throw new InvocationException ( "Illegal access invoking method [" + method + "]: " + e . getMessage ( ) , e ) ; } catch ( InvocationTargetException e ) { throw new InvocationException ( "Exception occurred invoking method [" + method + "]: " + e . getMessage ( ) , e ) ; } } | Invokes a method . |
21,198 | public static Field getRequiredField ( Class type , String name ) { try { return type . getDeclaredField ( name ) ; } catch ( NoSuchFieldException e ) { Optional < Field > field = findField ( type , name ) ; return field . orElseThrow ( ( ) -> new NoSuchFieldError ( "No field '" + name + "' found for type: " + type . getName ( ) ) ) ; } } | Finds a field on the given type for the given name . |
21,199 | static void exitWithError ( Boolean isDebug , Exception e ) { System . err . println ( "Error executing function (Use -x for more information): " + e . getMessage ( ) ) ; if ( isDebug ) { System . err . println ( ) ; System . err . println ( "Error Detail" ) ; System . err . println ( "------------" ) ; e . printStackTrace ( System . err ) ; } System . exit ( 1 ) ; } | Exit and print an error message if debug flag set . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.