MCPcopy Index your code
hub / github.com/google/dagger / unwrapOptional

Method unwrapOptional

java/dagger/internal/codegen/KeyFactory.java:437–447  ·  view source on GitHub ↗

If key's type is Optional for some T, returns a key with the same qualifier whose type is plain RequestKinds#extractKeyType(RequestKind, TypeMirror) extracted} from T.

(Key key)

Source from the content-addressed store, hash-verified

435 * extracted} from {@code T}.
436 */
437 Optional<Key> unwrapOptional(Key key) {
438 if (!OptionalType.isOptional(key)) {
439 return Optional.empty();
440 }
441
442 TypeMirror optionalValueType = OptionalType.from(key).valueType();
443 return Optional.of(
444 key.toBuilder()
445 .type(extractKeyType(getRequestKind(optionalValueType), optionalValueType))
446 .build());
447 }
448
449 /** Returns a key for a {@code @ForReleasableReferences(scope) ReleasableReferenceManager}. */
450 Key forReleasableReferenceManager(Scope scope) {

Calls 10

isOptionalMethod · 0.95
fromMethod · 0.95
extractKeyTypeMethod · 0.80
getRequestKindMethod · 0.80
buildMethod · 0.65
emptyMethod · 0.45
valueTypeMethod · 0.45
ofMethod · 0.45
typeMethod · 0.45
toBuilderMethod · 0.45

Tested by

no test coverage detected