MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / Sync

Class Sync

src/main/java/fieldbox/boxes/plugins/Pseudo.java:499–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497 }
498
499 static public class Sync implements AsMap {
500
501 private final Box on;
502
503 public Sync(Box on) {
504 this.on = on;
505 }
506
507 @Override
508 public boolean asMap_isProperty(String s) {
509 return true;
510 }
511
512 @Override
513 public Object asMap_call(Object o, Object o1) {
514 return asMap_getElement(o1);
515 }
516
517 @Override
518 public Object asMap_getElement(Object element) {
519 return asMap_get(element + "");
520 }
521
522 @Override
523 public Object asMap_setElement(int element, Object o) {
524 return null;
525 }
526
527 @Override
528 public Object asMap_get(String p) {
529 return null;
530 }
531
532 @Override
533 public Object asMap_set(String p, Object val) {
534
535 Supplier c = (Supplier) Conversions.convert(val, Supplier.class);
536
537 Object[] o = {null};
538
539 if (c != null) {
540 try {
541 ThreadSync.inMainThread(() -> {
542 o[0] = c.get();
543 });
544 } catch (InterruptedException e) {
545 throw (IllegalArgumentException) new IllegalArgumentException().initCause(e);
546 } catch (ExecutionException e) {
547 throw (IllegalArgumentException) new IllegalArgumentException().initCause(e);
548 }
549 }
550
551 return on.properties.put(new Dict.Prop(p), o[0]);
552 }
553
554
555 @Override
556 public Object asMap_new(Object a) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected