Skip to content

Instantly share code, notes, and snippets.

@ljnelson
Created December 16, 2016 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljnelson/660182c2aac0c60bb5effe9719dc7752 to your computer and use it in GitHub Desktop.
Save ljnelson/660182c2aac0c60bb5effe9719dc7752 to your computer and use it in GitHub Desktop.
@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