-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fca5c57
commit eb17309
Showing
6 changed files
with
141 additions
and
4 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
52 changes: 52 additions & 0 deletions
52
constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/KeepTrueSegment.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,52 @@ | ||
package gov.nasa.jpl.aerie.constraints.tree; | ||
|
||
import gov.nasa.jpl.aerie.constraints.model.EvaluationEnvironment; | ||
import gov.nasa.jpl.aerie.constraints.model.SimulationResults; | ||
import gov.nasa.jpl.aerie.constraints.time.Interval; | ||
import gov.nasa.jpl.aerie.constraints.time.Windows; | ||
|
||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
public class KeepTrueSegment implements Expression<Windows> { | ||
|
||
public final Expression<Windows> expression; | ||
public final int i; | ||
|
||
public KeepTrueSegment(final Expression<Windows> expression, final int i) { | ||
this.expression = expression; | ||
this.i = i; | ||
} | ||
|
||
@Override | ||
public Windows evaluate(final SimulationResults results, final Interval bounds, final EvaluationEnvironment environment) { | ||
return this.expression.evaluate(results, bounds, environment).keepTrueSegment(i); | ||
} | ||
|
||
@Override | ||
public String prettyPrint(final String prefix) { | ||
return String.format( | ||
"\n%s(%s[%d])", | ||
prefix, | ||
this.expression.prettyPrint(prefix + " "), | ||
i | ||
); } | ||
|
||
@Override | ||
public void extractResources(final Set<String> names) { | ||
this.expression.extractResources(names); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof final KeepTrueSegment o)) return false; | ||
|
||
return Objects.equals(this.expression, o.expression) && this.i == o.i; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(this.expression, this.i); | ||
} | ||
|
||
} |
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