-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from mP1/feature/SpreadsheetExpressionFunctio…
…nCellFormula SpreadsheetExpressionFunctionCellFormula
- Loading branch information
Showing
5 changed files
with
121 additions
and
0 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
48 changes: 48 additions & 0 deletions
48
...alkingkooka/spreadsheet/expression/function/SpreadsheetExpressionFunctionCellFormula.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,48 @@ | ||
/* | ||
* Copyright 2022 Miroslav Pokorny (github.com/mP1) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package walkingkooka.spreadsheet.expression.function; | ||
|
||
import walkingkooka.spreadsheet.SpreadsheetCell; | ||
import walkingkooka.spreadsheet.SpreadsheetFormula; | ||
|
||
/** | ||
* A custom function that retrieves the {@link SpreadsheetFormula} for the current cell. | ||
* <br> | ||
* This function exists primarily to support filtering cells using a predicate of the current cell. | ||
*/ | ||
final class SpreadsheetExpressionFunctionCellFormula extends SpreadsheetExpressionFunctionCell<SpreadsheetFormula> { | ||
|
||
/** | ||
* Singleton | ||
*/ | ||
final static SpreadsheetExpressionFunctionCellFormula INSTANCE = new SpreadsheetExpressionFunctionCellFormula(); | ||
|
||
private SpreadsheetExpressionFunctionCellFormula() { | ||
super("cellFormula"); | ||
} | ||
|
||
@Override | ||
public Class<SpreadsheetFormula> returnType() { | ||
return SpreadsheetFormula.class; | ||
} | ||
|
||
@Override | ||
SpreadsheetFormula extractCellPropertyOrNull(final SpreadsheetCell cell) { | ||
return cell.formula(); | ||
} | ||
} |
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
63 changes: 63 additions & 0 deletions
63
...ngkooka/spreadsheet/expression/function/SpreadsheetExpressionFunctionCellFormulaTest.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,63 @@ | ||
/* | ||
* Copyright 2022 Miroslav Pokorny (github.com/mP1) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package walkingkooka.spreadsheet.expression.function; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import walkingkooka.spreadsheet.SpreadsheetCell; | ||
import walkingkooka.spreadsheet.SpreadsheetFormula; | ||
|
||
public final class SpreadsheetExpressionFunctionCellFormulaTest extends SpreadsheetExpressionFunctionCellTestCase<SpreadsheetExpressionFunctionCellFormula, SpreadsheetFormula> { | ||
|
||
@Override | ||
public SpreadsheetExpressionFunctionCellFormula createBiFunction() { | ||
return SpreadsheetExpressionFunctionCellFormula.INSTANCE; | ||
} | ||
|
||
@Override | ||
SpreadsheetFormula valuePresent() { | ||
return SpreadsheetFormula.EMPTY.setText("=1+2"); | ||
} | ||
|
||
@Override | ||
SpreadsheetFormula valueAbsent() { | ||
return SpreadsheetFormula.EMPTY; | ||
} | ||
|
||
@Override | ||
SpreadsheetCell setProperty(final SpreadsheetCell cell, | ||
final SpreadsheetFormula formula) { | ||
return cell.setFormula(formula); | ||
} | ||
|
||
// toString......................................................................................................... | ||
|
||
@Test | ||
public void testToString() { | ||
this.toStringAndCheck( | ||
this.createBiFunction(), | ||
"cellFormula" | ||
); | ||
} | ||
|
||
// class............................................................................................................ | ||
|
||
@Override | ||
public Class<SpreadsheetExpressionFunctionCellFormula> type() { | ||
return SpreadsheetExpressionFunctionCellFormula.class; | ||
} | ||
} |