What does it mean to Animate a box? This class handles conversions from various dynamic language constructs to things with a beginning, a middle and an end. Runtimes can register things that can be converted into this format here with this registry. Question: should this just use the Conversions
| 15 | * and an end. Runtimes can register things that can be converted into this format here with this registry. |
| 16 | * <p> |
| 17 | * Question: should this just use the Conversions.java framework instead? |
| 18 | */ |
| 19 | public class Animatable { |
| 20 | |
| 21 | |
| 22 | public interface AnimationElement { |
| 23 | |
| 24 | default Object beginning(boolean isEnding) { |
| 25 | return this; |
| 26 | } |
| 27 | |
| 28 | default Object middle(boolean isEnding) { |
| 29 | return this; |
| 30 | } |
| 31 | |
| 32 | default Object end(boolean isEnding) { |
| 33 | return this; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | static public class Shim implements Supplier<Boolean>, Consumer<Boolean> { |
| 38 | protected final AnimationElement e; |
| 39 | protected boolean stopping = false; |
| 40 | protected boolean first = true; |
| 41 | |
| 42 | public Shim(AnimationElement e) { |
| 43 | this.e = e; |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public Boolean get() { |
| 48 | try { |
| 49 | if (first) { |
| 50 | first = false; |
| 51 | e.beginning(stopping); |
| 52 | return true; |
| 53 | } else if (stopping) { |
| 54 | e.end(stopping); |
| 55 | return false; |
| 56 | } else { |
| 57 | e.middle(stopping); |
| 58 | return true; |
| 59 | } |
| 60 | } catch (Throwable t) { |
| 61 | t.printStackTrace(); |
| 62 | Errors.INSTANCE.tryToReportTo(t, "Error thrown in box animation, box stopped", null); |
| 63 | |
| 64 | return false; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public void accept(Boolean willContinue) { |
| 70 | stopping = !willContinue; |
| 71 | } |
| 72 | |
| 73 | } |
| 74 |
nothing calls this directly
no test coverage detected