[New] added StrolchQuery.getSelection() and cleaned up some constants
This commit is contained in:
parent
d36267f640
commit
c21f96a5ae
|
@ -0,0 +1,23 @@
|
|||
package li.strolch.model;
|
||||
|
||||
import li.strolch.model.parameter.Parameter;
|
||||
|
||||
public class StrolchModelConstants {
|
||||
|
||||
/**
|
||||
* The type to set on {@link StrolchRootElement StrolchRootElements} when defining a template for a type of element
|
||||
*/
|
||||
public static final String TEMPLATE = "Template"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* This interpretation value indicates that the value of the {@link Parameter} should be understood as a reference
|
||||
* to a {@link Resource}
|
||||
*/
|
||||
public static final String INTERPRETATION_RESOURCE_REF = "Resource-Ref"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* This interpretation value indicates that the value of the {@link Parameter} should be understood as a reference
|
||||
* to an {@link Order}
|
||||
*/
|
||||
public static final String INTERPRETATION_ORDER_REF = "Order-Ref"; //$NON-NLS-1$
|
||||
}
|
|
@ -40,5 +40,4 @@ public class Tags {
|
|||
public static final String INCLUDE_FILE = "IncludeFile";
|
||||
public static final String FILE = "file";
|
||||
|
||||
public static final String TEMPLATE = "Template";
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package li.strolch.model.parameter;
|
|||
|
||||
import li.strolch.model.ParameterizedElement;
|
||||
import li.strolch.model.StrolchElement;
|
||||
import li.strolch.model.StrolchModelConstants;
|
||||
import li.strolch.model.visitor.ParameterVisitor;
|
||||
|
||||
/**
|
||||
|
@ -104,6 +105,7 @@ public interface Parameter<T> extends StrolchElement {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ParameterizedElement getParent();
|
||||
|
||||
/**
|
||||
|
@ -116,8 +118,8 @@ public interface Parameter<T> extends StrolchElement {
|
|||
* this {@link Parameter} means. Currently there are three definitions, but any String value can be used:
|
||||
* <ul>
|
||||
* <li>{@link Parameter#INTERPRETATION_NONE}</li>
|
||||
* <li>{@link Parameter#INTERPRETATION_ORDER_REF}</li>
|
||||
* <li>{@link Parameter#INTERPRETATION_RESOURCE_REF}</li>
|
||||
* <li>{@link StrolchModelConstants#INTERPRETATION_ORDER_REF}</li>
|
||||
* <li>{@link StrolchModelConstants#INTERPRETATION_RESOURCE_REF}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return string value
|
||||
|
@ -129,8 +131,8 @@ public interface Parameter<T> extends StrolchElement {
|
|||
* {@link Parameter} means. Currently there are three definitions, but any String value can be used:
|
||||
* <ul>
|
||||
* <li>{@link Parameter#INTERPRETATION_NONE}</li>
|
||||
* <li>{@link Parameter#INTERPRETATION_ORDER_REF}</li>
|
||||
* <li>{@link Parameter#INTERPRETATION_RESOURCE_REF}</li>
|
||||
* <li>{@link StrolchModelConstants#INTERPRETATION_ORDER_REF}</li>
|
||||
* <li>{@link StrolchModelConstants#INTERPRETATION_RESOURCE_REF}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param interpretation
|
||||
|
|
|
@ -57,6 +57,7 @@ public abstract class ParameterSelection implements Selection {
|
|||
accept((ParameterSelectionVisitor) visitor);
|
||||
}
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -243,7 +244,7 @@ public abstract class ParameterSelection implements Selection {
|
|||
|
||||
public DateRangeParameterSelection(String bagKey, String paramKey, Date from, Date to) {
|
||||
super(bagKey, paramKey);
|
||||
DBC.PRE.assertFalse("Either 'to' or 'from' must be set! Both can not be null!", from == null && to == null);
|
||||
DBC.PRE.assertFalse("Either 'to' or 'from' must be set! Both can not be null!", from == null && to == null); //$NON-NLS-1$
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
|
|
@ -28,43 +28,55 @@ public abstract class StrolchQuery<T extends QueryVisitor> {
|
|||
public StrolchQuery(Navigation navigation) {
|
||||
this.navigation = navigation;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasNavigation() {
|
||||
return navigation != null;
|
||||
}
|
||||
|
||||
public boolean hasSelection() {
|
||||
return selection != null && selection.hasSelection();
|
||||
return this.navigation != null;
|
||||
}
|
||||
|
||||
public void select(Selection selection) {
|
||||
DBC.PRE.assertNull("A selection is already set! Use a boolean operator to perform multiple selections",
|
||||
public boolean hasSelection() {
|
||||
return this.selection != null && this.selection.hasSelection();
|
||||
}
|
||||
|
||||
public Selection getSelection() {
|
||||
return this.selection;
|
||||
}
|
||||
|
||||
public void with(Selection selection) {
|
||||
DBC.PRE.assertNull("A selection is already set! Use a boolean operator to perform multiple selections", //$NON-NLS-1$
|
||||
this.selection);
|
||||
this.selection = selection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #with(Selection)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void select(Selection selection) {
|
||||
with(selection);
|
||||
}
|
||||
|
||||
public AndSelection and() {
|
||||
DBC.PRE.assertNull("A selection is already set! Create hierarchical boolean selections", this.selection);
|
||||
DBC.PRE.assertNull("A selection is already set! Create hierarchical boolean selections", this.selection); //$NON-NLS-1$
|
||||
AndSelection and = new AndSelection();
|
||||
this.selection = and;
|
||||
return and;
|
||||
}
|
||||
|
||||
public OrSelection or() {
|
||||
DBC.PRE.assertNull("A selection is already set! Create hierarchical boolean selections", this.selection);
|
||||
DBC.PRE.assertNull("A selection is already set! Create hierarchical boolean selections", this.selection); //$NON-NLS-1$
|
||||
OrSelection or = new OrSelection();
|
||||
this.selection = or;
|
||||
return or;
|
||||
}
|
||||
|
||||
public void not(Selection selection) {
|
||||
DBC.PRE.assertNull("A selection is already set! Create hierarchical boolean selections", this.selection);
|
||||
DBC.PRE.assertNull("A selection is already set! Create hierarchical boolean selections", this.selection); //$NON-NLS-1$
|
||||
this.selection = new NotSelection(selection);
|
||||
}
|
||||
|
||||
public void accept(T visitor) {
|
||||
DBC.PRE.assertNotNull("No navigation set!", this.navigation);
|
||||
DBC.PRE.assertNotNull("No selection defined!", this.selection);
|
||||
DBC.PRE.assertNotNull("No navigation set!", this.navigation); //$NON-NLS-1$
|
||||
DBC.PRE.assertNotNull("No selection defined!", this.selection); //$NON-NLS-1$
|
||||
this.navigation.accept(visitor);
|
||||
this.selection.accept(visitor);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue