Skip to content

Commit

Permalink
Fixed signature of Bags.FilterElements
Browse files Browse the repository at this point in the history
The original signature expected a descendant of UnaryFunction,
but this would prevent passing other functions, such as a
FunctionTree of input arity 1.

Closes #48
  • Loading branch information
sylvainhalle committed Sep 30, 2021
1 parent 295bfa1 commit d095072
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Core/src/ca/uqac/lif/cep/util/Bags.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
BeepBeep, an event stream processor
Copyright (C) 2008-2020 Sylvain Hallé
Copyright (C) 2008-2021 Sylvain Hallé
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
Expand Down Expand Up @@ -101,7 +101,7 @@ public static class FilterElements extends UnaryFunction<Object, Object>
/**
* The condition to evaluate on each element
*/
protected UnaryFunction<?, Boolean> m_condition;
protected Function m_condition;

// This constructor is used for deserialization.
protected FilterElements()
Expand All @@ -110,24 +110,28 @@ protected FilterElements()
}

/**
* Gets a new instance of the function
* Gets a new instance of the function.
*
* @param condition
* The condition to evaluate on each element
* The condition to evaluate on each element. This function must
* be of arity 1 and return a Boolean value.
*/
public FilterElements(UnaryFunction<?, Boolean> condition)
/*@ requires condition.getInputArity() == 1; @*/
public FilterElements(Function condition)
{
this();
m_condition = condition;
}

/**
* Sets the condition to evaluate on each element
* Sets the condition to evaluate on each element.
*
* @param condition
* The condition
* The condition to evaluate on each element. This function must
* be of arity 1 and return a Boolean value.
*/
public void setCondition(UnaryFunction<Object, Boolean> condition)
/*@ requires condition.getInputArity() == 1; @*/
public void setCondition(Function condition)
{
m_condition = condition;
}
Expand Down

0 comments on commit d095072

Please sign in to comment.