Browse Source
We now correctly add a compound expression that represents a field reference to the previous operation arguments if necessary. Original pull request: #118.pull/118/merge
6 changed files with 254 additions and 3 deletions
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
/* |
||||
* Copyright 2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.aggregation; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Thomas Darimont |
||||
*/ |
||||
public class Invoice { |
||||
|
||||
String orderId; |
||||
|
||||
double taxAmount; |
||||
|
||||
double netAmount; |
||||
|
||||
double totalAmount; |
||||
|
||||
List<LineItem> items; |
||||
|
||||
public String getOrderId() { |
||||
return orderId; |
||||
} |
||||
|
||||
public void setOrderId(String orderId) { |
||||
this.orderId = orderId; |
||||
} |
||||
|
||||
public double getTaxAmount() { |
||||
return taxAmount; |
||||
} |
||||
|
||||
public void setTaxAmount(double taxAmount) { |
||||
this.taxAmount = taxAmount; |
||||
} |
||||
|
||||
public double getNetAmount() { |
||||
return netAmount; |
||||
} |
||||
|
||||
public void setNetAmount(double netAmount) { |
||||
this.netAmount = netAmount; |
||||
} |
||||
|
||||
public double getTotalAmount() { |
||||
return totalAmount; |
||||
} |
||||
|
||||
public void setTotalAmount(double totalAmount) { |
||||
this.totalAmount = totalAmount; |
||||
} |
||||
|
||||
public List<LineItem> getItems() { |
||||
return items; |
||||
} |
||||
|
||||
public void setItems(List<LineItem> items) { |
||||
this.items = items; |
||||
} |
||||
} |
||||
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
/* |
||||
* Copyright 2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.aggregation; |
||||
|
||||
/** |
||||
* @author Thomas Darimont |
||||
*/ |
||||
public class LineItem { |
||||
|
||||
final String id; |
||||
|
||||
final String caption; |
||||
|
||||
final double price; |
||||
|
||||
int quantity = 1; |
||||
|
||||
@SuppressWarnings("unused") |
||||
private LineItem() { |
||||
this(null, null, 0.0, 0); |
||||
} |
||||
|
||||
public LineItem(String id, String caption, double price) { |
||||
this.id = id; |
||||
this.caption = caption; |
||||
this.price = price; |
||||
} |
||||
|
||||
public LineItem(String id, String caption, double price, int quantity) { |
||||
this(id, caption, price); |
||||
this.quantity = quantity; |
||||
} |
||||
} |
||||
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
/* |
||||
* Copyright 2014 the original author or authors. |
||||
* |
||||
* 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 org.springframework.data.mongodb.core.aggregation; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Thomas Darimont |
||||
*/ |
||||
public class Order { |
||||
|
||||
final String id; |
||||
|
||||
final String customerId; |
||||
|
||||
final Date orderDate; |
||||
|
||||
final List<LineItem> items; |
||||
|
||||
public Order(String id, String customerId, Date orderDate) { |
||||
this(id, customerId, orderDate, new ArrayList<LineItem>()); |
||||
} |
||||
|
||||
public Order(String id, String customerId, Date orderDate, List<LineItem> items) { |
||||
this.id = id; |
||||
this.customerId = customerId; |
||||
this.orderDate = orderDate; |
||||
this.items = items; |
||||
} |
||||
|
||||
public Order addItem(LineItem item) { |
||||
|
||||
List<LineItem> newItems = new ArrayList<LineItem>(items != null ? items : Collections.<LineItem> emptyList()); |
||||
newItems.add(item); |
||||
|
||||
return new Order(id, customerId, orderDate, newItems); |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public String getCustomerId() { |
||||
return customerId; |
||||
} |
||||
|
||||
public Date getOrderDate() { |
||||
return orderDate; |
||||
} |
||||
|
||||
public List<LineItem> getItems() { |
||||
return items; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue