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 ( file...
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 = resourceResolv...
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 ) ; } retu...
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 ] . laz...
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 )...
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 . getArgumen...
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 ( ) ...
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 ( syst...
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 comple...
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 ( ) )...
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 ( ) ;...
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 ( ...
Append a message .
21,134
private Publisher < GetParametersByPathResult > getHierarchy ( String path ) { GetParametersByPathRequest getRequest = new GetParametersByPathRequest ( ) . withWithDecryption ( awsParameterStoreConfiguration . getUseSecureParameters ( ) ) . withPath ( path ) . withRecursive ( true ) ; Future < GetParametersByPathResult...
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 ( getRe...
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 ( ) ....
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 : methodDescriptor...
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 ) ; } protec...
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 ) { @ SuppressWarnin...
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 . Annotatio...
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 , re...
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 ( St...
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 ) { visitBe...
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 ( annotationM...
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 = ...
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 classNameWithPathSepar...
Find a resource for class name .
21,156
public AbstractConfigurableTemplateResolver templateResolver ( ViewsConfiguration viewsConfiguration , ThymeleafViewsRendererConfiguration rendererConfiguration ) { ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver ( ) ; templateResolver . setPrefix ( viewsConfiguration . getFolder ( ) ) ; ...
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 . setTemplat...
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 > sch...
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 ) { i...
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 . INTERN...
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://" + instanceSumma...
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 ...
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 ( serviceFilte...
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 ( ) ) ; } retu...
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 " + op...
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...
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 . nextEl...
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 (...
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...
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 ) && ! ...
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 != ...
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 ) && m...
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 -> Se...
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 ...
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 (...
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 < Str...
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 ( I...
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 . g...
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 . printStackT...
Exit and print an error message if debug flag set .