2020-05-23 10:25:22 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const Expression = require('./expression');
|
|
|
|
const NoteSet = require('../note_set');
|
|
|
|
|
|
|
|
class PropertyComparisonExp extends Expression {
|
|
|
|
constructor(propertyName, comparator) {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.propertyName = propertyName;
|
|
|
|
this.comparator = comparator;
|
|
|
|
}
|
|
|
|
|
2020-05-23 12:27:44 +02:00
|
|
|
execute(inputNoteSet, searchContext) {
|
2020-05-23 10:25:22 +02:00
|
|
|
const resNoteSet = new NoteSet();
|
|
|
|
|
2020-05-23 12:27:44 +02:00
|
|
|
for (const note of inputNoteSet.notes) {
|
2020-05-23 10:25:22 +02:00
|
|
|
const value = note[this.propertyName].toLowerCase();
|
|
|
|
|
|
|
|
if (this.comparator(value)) {
|
|
|
|
resNoteSet.add(note);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return resNoteSet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = PropertyComparisonExp;
|