[New] Added orderBy*() methods without need for BAG_PARAMETERS, or reverse flag

This commit is contained in:
Robert von Burg 2020-01-20 11:18:21 +01:00
parent 63392ca8c8
commit 085335d393
1 changed files with 44 additions and 0 deletions

View File

@ -1,9 +1,13 @@
package li.strolch.search;
import static li.strolch.model.StrolchModelConstants.BAG_PARAMETERS;
import java.util.Comparator;
import java.util.stream.Stream;
import li.strolch.model.ParameterBag;
import li.strolch.model.StrolchElement;
import li.strolch.model.StrolchModelConstants;
import li.strolch.model.StrolchRootElement;
import li.strolch.model.parameter.Parameter;
import li.strolch.model.visitor.StrolchRootElementVisitor;
@ -19,6 +23,16 @@ public class RootElementSearchResult<T extends StrolchRootElement> extends Searc
super(stream);
}
/**
* Appends a comparator to the stream of elements to compare by ID
*
* @return this for chaining
*/
public RootElementSearchResult<T> orderById() {
orderById(false);
return this;
}
/**
* Appends a comparator to the stream of elements to compare by ID
*
@ -60,6 +74,36 @@ public class RootElementSearchResult<T extends StrolchRootElement> extends Searc
return this;
}
/**
* Appends a comparator to the stream of elements to compare by a parameter on the {@link ParameterBag} with the ID
* {@link StrolchModelConstants#BAG_PARAMETERS}
*
* @param paramId
* the ID of the parameter to use for comparing
*
* @return this for chaining
*/
public RootElementSearchResult<T> orderByParam(String paramId) {
orderByParam(BAG_PARAMETERS, paramId, false);
return this;
}
/**
* Appends a comparator to the stream of elements to compare by a parameter on the {@link ParameterBag} with the ID
* {@link StrolchModelConstants#BAG_PARAMETERS}
*
* @param paramId
* the ID of the parameter to use for comparing
* @param reversed
* flag to reverse the comparison
*
* @return this for chaining
*/
public RootElementSearchResult<T> orderByParam(String paramId, boolean reversed) {
orderByParam(BAG_PARAMETERS, paramId, reversed);
return this;
}
/**
* Appends a comparator to the stream of elements to compare by a parameter
*