(String name, Object value)
| 503 | public boolean asMap_delete(Object o) { |
| 504 | return Missing.delete(this, new Dict.Prop("" + o)) != null; |
| 505 | } |
| 506 | |
| 507 | @Override |
| 508 | @HiddenInAutocomplete |
| 509 | public Object asMap_set(String name, Object value) { |
| 510 | |
| 511 | // workaround bug in Nashorn |
| 512 | // if (value instanceof ConsString) value = value.toString(); //jdk9 module security breaks this |
| 513 | if (value != null && value.getClass().getName().endsWith("ConsString")) value = "" + value; |
| 514 | |
| 515 | Dict.Prop canon = new Dict.Prop(name).toCanon(); |
| 516 | |
| 517 | if (canon.getAttributes().isTrue(Dict.readOnly, false)) |
| 518 | throw new IllegalArgumentException("can't write to property " + name); |
| 519 | |
| 520 | /* |
| 521 | if (value instanceof Iterable && canon.getTypeInformation()!=null && !Iterable.class.isAssignableFrom((Class<?>) canon.getTypeInformation().get(0))) |
| 522 | { |
| 523 | value = Drivers.iterableAsTrappedSet((Iterable)value); |
| 524 | } |
| 525 | */ |
| 526 | if (value instanceof Iterator && canon.getTypeInformation()!=null && !Iterable.class.isAssignableFrom((Class<?>) canon.getTypeInformation().get(0))) |
| 527 | { |
| 528 | value = Drivers.iteratorAsTrappedSet((Iterator)value); |
| 529 | } |
| 530 | |
| 531 | if (value instanceof ThreadSync2.TrappedSet) { |
| 532 | Object firstValue = ((ThreadSync2.TrappedSet) value).next(); |
| 533 | |
| 534 | Object r = asMap_set(name, firstValue); |
| 535 | |
| 536 | Drivers.provokeCurrentFibre(System.identityHashCode(this) + "_" + name, new Function1<Object, Object>() { |
| 537 | @Override |
| 538 | public Object invoke(Object o) { |
| 539 | if (o != null) { |
| 540 | asMap_set(name, o); |
| 541 | } |
| 542 | return o; |
| 543 | } |
| 544 | }, ((ThreadSync2.TrappedSet) value)); |
| 545 | |
| 546 | return r; |
| 547 | } |
| 548 | |
| 549 | Function<Object, Object> c = canon.getAttributes().get(Dict.customCaster); |
| 550 | if (c != null) |
| 551 | value = c.apply(value); |
| 552 | |
| 553 | Object converted = Conversions.convert(value, canon.getTypeInformation()); |
| 554 | |
| 555 | Missing.setTo(this, canon, converted); |
| 556 | |
| 557 | if (tick != RunLoop.tick) { |
| 558 | // Drawing.dirty(this); |
| 559 | tick = RunLoop.tick; |
| 560 | } |
| 561 | |
| 562 | return this; |
no test coverage detected