This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Buildfix for mvn compile -P static
- Loading branch information
Showing
24 changed files
with
3,259 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
blinky-util/src/main/java/org/spideruci/analysis/statik/controlflow/Accumulator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.spideruci.analysis.statik.controlflow; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.function.Consumer; | ||
|
||
/** | ||
* A collection that is designed to only add Node elements to a list | ||
* return such a list upon adding all desired Nodes. | ||
* @author vpalepu | ||
* | ||
* @param <T> | ||
*/ | ||
public class Accumulator<T> { | ||
|
||
private ArrayList<Node<T>> accumulated; | ||
|
||
/** | ||
* Creates an Accumulator instance. | ||
* @return | ||
*/ | ||
public static <A> Accumulator<A> create() { | ||
return new Accumulator<A>(); | ||
} | ||
|
||
private Accumulator() { | ||
accumulated = new ArrayList<>(); | ||
} | ||
|
||
/** | ||
* Retrieves the current list of Nodes accumulated so far. | ||
* @return | ||
*/ | ||
public ArrayList<Node<T>> period() { | ||
return new ArrayList<Node<T>>(accumulated); | ||
} | ||
|
||
public ArrayList<Node<T>> andAlso(Node<T> node) { | ||
accumulated.add(node); | ||
return new ArrayList<>(accumulated); | ||
} | ||
|
||
public Accumulator<T> and(Node<T> node) { | ||
this.accumulated.add(node); | ||
return this; | ||
} | ||
|
||
public Accumulator<T> with(Node<T>[] nodes) { | ||
for(Node<T> node : nodes) { | ||
and(node); | ||
} | ||
return this; | ||
} | ||
|
||
public Accumulator<T> with(Collection<Node<T>> nodes) { | ||
for(Node<T> node : nodes) { | ||
and(node); | ||
} | ||
return this; | ||
} | ||
|
||
public void forEach(Consumer<Node<T>> c) { | ||
accumulated.forEach(c); | ||
} | ||
|
||
} |
Oops, something went wrong.