public class Monoflop extends Object
All successive calls will not change the internal state, and return constantly true (or respectively).
This is particularly useful in loops where the first iteration must be handled differently. Therefore two more
functions are provided: firstCall()
and successiveCall()
which can be used like shown here:
Monoflop mono = Monoflop.create();
StringBuilder sb = new StringBuilder();
for(String value : somelist) {
if (mono.successiveCall()) {
sb.append(", ");
}
sb.append(value);
}
System.out.println(sb.toString());
Modifier and Type | Method and Description |
---|---|
static Monoflop |
create()
Creates a new monoflop.
|
boolean |
firstCall()
Reads and then toggles the monoflop.
|
boolean |
inverseToggle()
Toggles the monoflop and returns its state before it was toggled.
|
boolean |
isToggled()
Reads the internal state without toggling it.
|
boolean |
successiveCall()
Reads and then toggles the monoflop.
|
boolean |
toggle()
Toggles the monoflop and returns its state before it was toggled.
|
String |
toString() |
public static Monoflop create()
public boolean toggle()
If the monoflop is in its initial state, this will return false (and toggle the monoflop). Therefore all successive class will return true.
public boolean inverseToggle()
If the monoflop is in its initial state, this will return true (and toggle the monoflop). Therefore all successive class will return false.
public boolean firstCall()
If the monoflop is in its initial state, this will return true (and toggle the monoflop). Therefore all successive class will return false.
This is just an alias for inverseToggle()
.
public boolean successiveCall()
If the monoflop is in its initial state, this will return false (and toggle the monoflop). Therefore all successive class will return true.
This is just an alias for toggle()
.
public boolean isToggled()
Copyright © 2018. All rights reserved.