| 574 | } |
| 575 | |
| 576 | static public class First implements AsMap { |
| 577 | |
| 578 | protected final Box on; |
| 579 | |
| 580 | public First(Box on) { |
| 581 | this.on = on; |
| 582 | } |
| 583 | |
| 584 | @Override |
| 585 | public boolean asMap_isProperty(String s) { |
| 586 | return true; |
| 587 | } |
| 588 | |
| 589 | @Override |
| 590 | public Object asMap_call(Object o, Object o1) { |
| 591 | return null; |
| 592 | } |
| 593 | |
| 594 | @Override |
| 595 | public boolean asMap_delete(Object o) { |
| 596 | Box q = (Box) asMap_get("" + o); |
| 597 | if (q != null) { |
| 598 | return q.properties.asMap_delete(o); |
| 599 | } |
| 600 | return false; |
| 601 | } |
| 602 | |
| 603 | @Override |
| 604 | public Object asMap_get(String s) { |
| 605 | Dict.Prop p = new Dict.Prop(s); |
| 606 | return on.breadthFirst(on.upwards()) |
| 607 | .filter(x -> x.properties.has(p)) |
| 608 | .findFirst() |
| 609 | .orElseGet(() -> null); |
| 610 | } |
| 611 | |
| 612 | @Override |
| 613 | public Object asMap_set(String s, Object o) { |
| 614 | |
| 615 | if (o instanceof Box) { |
| 616 | Dict.Prop p = new Dict.Prop(s); |
| 617 | return on.breadthFirst(on.upwards()) |
| 618 | .filter(x -> x.properties.has(p)) |
| 619 | .findFirst() |
| 620 | .map(x -> { |
| 621 | Object v = x.properties.remove(p); |
| 622 | ((Box) o).properties.put(p, v); |
| 623 | return v; |
| 624 | }); |
| 625 | } else { |
| 626 | throw new IllegalArgumentException(" can't move property to something that isn't a box"); |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | |
| 631 | @Override |
| 632 | public Object asMap_new(Object o) { |
| 633 | return null; |
nothing calls this directly
no outgoing calls
no test coverage detected