Created
December 16, 2016 04:35
-
-
Save ljnelson/660182c2aac0c60bb5effe9719dc7752 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Produces | |
@Dependent | |
@Property | |
private static final Object produceProperty(final InjectionPoint injectionPoint, final BigCoConfigurationEngine config) { | |
Objects.requireNonNull(config); | |
Object returnValue = null; | |
if (injectionPoint == null) { | |
// This is a case that really shouldn't happen. | |
return null; // ok to do with Dependent scope | |
} else { | |
final Set<Annotation> qualifiers = injectionPoint.getQualifiers(); | |
assert qualifiers != null; | |
assert !qualifiers.isEmpty(); | |
final Optional<Annotation> propertyAnnotation = qualifiers.stream().filter((annotation) -> { | |
return annotation instanceof Property; | |
}).findFirst(); | |
assert propertyAnnotation.isPresent(); | |
final Property property = Property.class.cast(propertyAnnotation.get()); | |
assert property != null; | |
final String name = property.value(); | |
assert name != null; | |
returnValue = config.get(name); | |
} | |
return returnValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment