jodd-petite/src/main/java/jodd/petite/resolver/ReferencesResolver.java
public BeanReferences[] readAllReferencesFromAnnotation(final Executable methodOrCtor) {
		PetiteInject petiteInject = methodOrCtor.getAnnotation(PetiteInject.class);

		final Parameter[] parameters = methodOrCtor.getParameters();

		BeanReferences[] references;

		final boolean hasAnnotationOnMethodOrCtor;

		if (petiteInject != null) {
			references = convertAnnValueToReferences(petiteInject.value());

			hasAnnotationOnMethodOrCtor = true;
		}
		else {
			references = new BeanReferences[parameters.length];

			hasAnnotationOnMethodOrCtor = false;
		}

		int parametersWithAnnotationCount = 0;

		for (int i = 0; i < parameters.length; i++) {
			Parameter parameter = parameters[i];

			petiteInject = parameter.getAnnotation(PetiteInject.class);

			if (petiteInject == null) {
				// no annotation on argument
				continue;
			}

			// there is annotation on argument, override values
			String annotationValue = readAnnotationValue(petiteInject);

			if (annotationValue != null) {
				references[i] = BeanReferences.of(annotationValue);
			}

			parametersWithAnnotationCount++;
		}

		if (!hasAnnotationOnMethodOrCtor) {
			if (parametersWithAnnotationCount == 0) {
				return null;
			}
			if (parametersWithAnnotationCount != parameters.length) {
				throw new PetiteException("All arguments must be annotated with PetiteInject");
			}
		}

		references = updateReferencesWithDefaultsIfNeeded(methodOrCtor, references);

		removeAllDuplicateNames(references);

		return references;
	}
public BeanReferences[] readAllReferencesFromAnnotation(final Executable methodOrCtor) {
		PetiteInject petiteInject = methodOrCtor.getAnnotation(PetiteInject.class);

		final Parameter[] parameters = methodOrCtor.getParameters();

		BeanReferences[] references;

		final boolean hasAnnotationOnMethodOrCtor;

		if (petiteInject != null) {
			references = convertAnnValueToReferences(petiteInject.value());

			hasAnnotationOnMethodOrCtor = true;
		}
		else {
			references = new BeanReferences[parameters.length];

			hasAnnotationOnMethodOrCtor = false;
		}

		int parametersWithAnnotationCount = 0;

		for (int i = 0; i < parameters.length; i++) {
			Parameter parameter = parameters[i];

			petiteInject = parameter.getAnnotation(PetiteInject.class);

			if (petiteInject == null) {
				// no annotation on argument
				continue;
			}

			// there is annotation on argument, override values
			String annotationValue = readAnnotationValue(petiteInject);

			if (annotationValue != null) {
				references[i] = BeanReferences.of(annotationValue);
			}

			parametersWithAnnotationCount++;
		}

		if (!hasAnnotationOnMethodOrCtor) {
			if (parametersWithAnnotationCount == 0) {
				return null;
			}
			if (parametersWithAnnotationCount != parameters.length) {
				throw new PetiteException("All arguments must be annotated with PetiteInject");
			}
		}

		references = updateReferencesWithDefaultsIfNeeded(methodOrCtor, references);

		removeAllDuplicateNames(references);

		return references;
	}
public BeanReferences [ ] readAllReferencesFromAnnotation ( final Executable methodOrCtor ) { PetiteInject petiteInject = methodOrCtor . getAnnotation ( PetiteInject . class ) ; final Parameter [ ] parameters = methodOrCtor . getParameters ( ) ; BeanReferences [ ] references ; final boolean hasAnnotationOnMethodOrCtor ; if ( petiteInject != null ) { references = convertAnnValueToReferences ( petiteInject . value ( ) ) ; hasAnnotationOnMethodOrCtor = true ; } else { references = new BeanReferences [ parameters . length ] ; hasAnnotationOnMethodOrCtor = false ; } int parametersWithAnnotationCount = 0 ; for ( int i = 0 ; i < parameters . length ; i ++ ) { Parameter parameter = parameters [ i ] ; petiteInject = parameter . getAnnotation ( PetiteInject . class ) ; if ( petiteInject == null ) { // no annotation on argument continue ; } // there is annotation on argument, override values String annotationValue = readAnnotationValue ( petiteInject ) ; if ( annotationValue != null ) { references [ i ] = BeanReferences . of ( annotationValue ) ; } parametersWithAnnotationCount ++ ; } if ( ! hasAnnotationOnMethodOrCtor ) { if ( parametersWithAnnotationCount == 0 ) { return null ; } if ( parametersWithAnnotationCount != parameters . length ) { throw new PetiteException ( "All arguments must be annotated with PetiteInject" ) ; } } references = updateReferencesWithDefaultsIfNeeded ( methodOrCtor , references ) ; removeAllDuplicateNames ( references ) ; return references ; }
Extracts references from method or constructor annotation.
Extracts references from method or constructor annotation .