View Javadoc
1   /*
2    * License : The MIT License
3    * Copyright(c) 2022 Olyutorskii
4    */
5   
6   package io.github.olyutorskii.aletojio.idling;
7   
8   /**
9    * Abstract {@link RndMonitor} implements.
10   */
11  public abstract class AbstractRndMonitor implements RndMonitor {
12  
13      private boolean meet = false;
14  
15  
16      /**
17       * Constructor.
18       */
19      protected AbstractRndMonitor() {
20          super();
21          return;
22      }
23  
24  
25      /**
26       * {@inheritDoc}
27       */
28      @Override
29      public void reset() {
30          this.meet = false;
31          resetImpl();
32          return;
33      }
34  
35      /**
36       * Implement of {@link #reset()}.
37       */
38      protected abstract void resetImpl();
39  
40      /**
41       * {@inheritDoc}
42       *
43       * @param iVal {@inheritDoc}
44       * @return {@inheritDoc}
45       */
46      @Override
47      public boolean probe(int iVal) {
48          if (this.meet) {
49              return true;
50          }
51  
52          if (probeImpl(iVal)) {
53              this.meet = true;
54          }
55  
56          return this.meet;
57      }
58  
59      /**
60       * Implement of {@link #probe(int)}.
61       *
62       * @param iVal int value
63       * @return true if
64       */
65      protected abstract boolean probeImpl(int iVal);
66  
67      /**
68       * {@inheritDoc}
69       *
70       * @return {@inheritDoc}
71       */
72      @Override
73      public boolean hasMet() {
74          return this.meet;
75      }
76  
77  }