|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2013 the original author or authors. |
|
|
|
* Copyright 2013-2014 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -252,7 +252,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
public ExpressionProjectionOperationBuilder(Object value, ProjectionOperation operation, Object[] parameters) { |
|
|
|
public ExpressionProjectionOperationBuilder(Object value, ProjectionOperation operation, Object[] parameters) { |
|
|
|
|
|
|
|
|
|
|
|
super(value, operation); |
|
|
|
super(value, operation); |
|
|
|
this.params = parameters; |
|
|
|
this.params = parameters.clone(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
@ -294,7 +294,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
Assert.notNull(parameters, "Parameters must not be null!"); |
|
|
|
Assert.notNull(parameters, "Parameters must not be null!"); |
|
|
|
|
|
|
|
|
|
|
|
this.expression = expression; |
|
|
|
this.expression = expression; |
|
|
|
this.params = parameters; |
|
|
|
this.params = parameters.clone(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
@ -316,6 +316,9 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static class ProjectionOperationBuilder extends AbstractProjectionOperationBuilder { |
|
|
|
public static class ProjectionOperationBuilder extends AbstractProjectionOperationBuilder { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String NUMBER_NOT_NULL = "Number must not be null!"; |
|
|
|
|
|
|
|
private static final String FIELD_REFERENCE_NOT_NULL = "Field reference must not be null!"; |
|
|
|
|
|
|
|
|
|
|
|
private final String name; |
|
|
|
private final String name; |
|
|
|
private final ProjectionOperation operation; |
|
|
|
private final ProjectionOperation operation; |
|
|
|
private final OperationProjection previousProjection; |
|
|
|
private final OperationProjection previousProjection; |
|
|
|
@ -382,7 +385,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProjectionOperationBuilder plus(Number number) { |
|
|
|
public ProjectionOperationBuilder plus(Number number) { |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(number, "Number must not be null!"); |
|
|
|
Assert.notNull(number, NUMBER_NOT_NULL); |
|
|
|
return project("add", number); |
|
|
|
return project("add", number); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -419,7 +422,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProjectionOperationBuilder minus(String fieldReference) { |
|
|
|
public ProjectionOperationBuilder minus(String fieldReference) { |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(fieldReference, "Field reference must not be null!"); |
|
|
|
Assert.notNull(fieldReference, FIELD_REFERENCE_NOT_NULL); |
|
|
|
return project("subtract", Fields.field(fieldReference)); |
|
|
|
return project("subtract", Fields.field(fieldReference)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -431,7 +434,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProjectionOperationBuilder multiply(Number number) { |
|
|
|
public ProjectionOperationBuilder multiply(Number number) { |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(number, "Number must not be null!"); |
|
|
|
Assert.notNull(number, NUMBER_NOT_NULL); |
|
|
|
return project("multiply", number); |
|
|
|
return project("multiply", number); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -444,7 +447,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProjectionOperationBuilder multiply(String fieldReference) { |
|
|
|
public ProjectionOperationBuilder multiply(String fieldReference) { |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(fieldReference, "Field reference must not be null!"); |
|
|
|
Assert.notNull(fieldReference, FIELD_REFERENCE_NOT_NULL); |
|
|
|
return project("multiply", Fields.field(fieldReference)); |
|
|
|
return project("multiply", Fields.field(fieldReference)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -456,7 +459,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProjectionOperationBuilder divide(Number number) { |
|
|
|
public ProjectionOperationBuilder divide(Number number) { |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(number, "Number must not be null!"); |
|
|
|
Assert.notNull(number, FIELD_REFERENCE_NOT_NULL); |
|
|
|
Assert.isTrue(Math.abs(number.intValue()) != 0, "Number must not be zero!"); |
|
|
|
Assert.isTrue(Math.abs(number.intValue()) != 0, "Number must not be zero!"); |
|
|
|
return project("divide", number); |
|
|
|
return project("divide", number); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -470,7 +473,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProjectionOperationBuilder divide(String fieldReference) { |
|
|
|
public ProjectionOperationBuilder divide(String fieldReference) { |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(fieldReference, "Field reference must not be null!"); |
|
|
|
Assert.notNull(fieldReference, FIELD_REFERENCE_NOT_NULL); |
|
|
|
return project("divide", Fields.field(fieldReference)); |
|
|
|
return project("divide", Fields.field(fieldReference)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -483,7 +486,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProjectionOperationBuilder mod(Number number) { |
|
|
|
public ProjectionOperationBuilder mod(Number number) { |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(number, "Number must not be null!"); |
|
|
|
Assert.notNull(number, NUMBER_NOT_NULL); |
|
|
|
Assert.isTrue(Math.abs(number.intValue()) != 0, "Number must not be zero!"); |
|
|
|
Assert.isTrue(Math.abs(number.intValue()) != 0, "Number must not be zero!"); |
|
|
|
return project("mod", number); |
|
|
|
return project("mod", number); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -497,7 +500,7 @@ public class ProjectionOperation implements FieldsExposingAggregationOperation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProjectionOperationBuilder mod(String fieldReference) { |
|
|
|
public ProjectionOperationBuilder mod(String fieldReference) { |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(fieldReference, "Field reference must not be null!"); |
|
|
|
Assert.notNull(fieldReference, FIELD_REFERENCE_NOT_NULL); |
|
|
|
return project("mod", Fields.field(fieldReference)); |
|
|
|
return project("mod", Fields.field(fieldReference)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|