MCPcopy Create free account
hub / github.com/BaseXdb/basex / opt

Method opt

basex-core/src/main/java/org/basex/query/func/map/MapEntry.java:29–44  ·  view source on GitHub ↗
(final CompileContext cc)

Source from the content-addressed store, hash-verified

27 }
28
29 @Override
30 protected Expr opt(final CompileContext cc) {
31 final Expr key = arg(0), value = arg(1);
32
33 final Type type;
34 if(key instanceof final Str str && key.seqType().eq(Types.STRING_O)) {
35 final TokenObjectMap<RecordField> fields = new TokenObjectMap<>(1);
36 fields.put(str.string(), new RecordField(value.seqType()));
37 type = cc.qc.shared.record(new RecordType(fields));
38 } else {
39 final BasicType kt = key.seqType().type.atomic();
40 type = MapType.get(kt != null ? kt : BasicType.ANY_ATOMIC_TYPE, value.seqType());
41 }
42 exprType.assign(type);
43 return this;
44 }
45
46 @Override
47 public long structSize() {

Callers

nothing calls this directly

Calls 9

seqTypeMethod · 0.95
putMethod · 0.95
getMethod · 0.95
eqMethod · 0.65
atomicMethod · 0.65
argMethod · 0.45
stringMethod · 0.45
recordMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected