BrightSide Workbench Full Report + Source Code
org.turro.financials.cart.delivery.DeliveryContexts Class Reference
Inheritance diagram for org.turro.financials.cart.delivery.DeliveryContexts:
Collaboration diagram for org.turro.financials.cart.delivery.DeliveryContexts:

Public Member Functions

Product getDeliveryProduct (Address address)
 
Product getDeliveryProduct (String value)
 
Set< String > getDeliveryValues ()
 
List< StreetItemgetDeliveryStreets (String search)
 
boolean isStreetBased ()
 
void readXML (Element root)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 33 of file DeliveryContexts.java.

Member Function Documentation

◆ getDeliveryProduct() [1/2]

Product org.turro.financials.cart.delivery.DeliveryContexts.getDeliveryProduct ( Address  address)

Definition at line 35 of file DeliveryContexts.java.

35  {
36  for(DeliveryContext dc : this) {
37  if(dc instanceof StreetMapContext) {
38  if(dc.match(address.getAddressString())) {
39  Product p = dc.getDeliveryProduct();
40  if(p != null) {
41  return p;
42  }
43  }
44  } else if(dc instanceof ZipcodeContext) {
45  if(dc.match(address.getZipCode())) {
46  Product p = dc.getDeliveryProduct();
47  if(p != null) {
48  return p;
49  }
50  }
51  } else if(dc instanceof ProvinceContext) {
52  if(dc.match(address.getProvince())) {
53  Product p = dc.getDeliveryProduct();
54  if(p != null) {
55  return p;
56  }
57  }
58  }
59  }
60  return null;
61  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDeliveryProduct() [2/2]

Product org.turro.financials.cart.delivery.DeliveryContexts.getDeliveryProduct ( String  value)

Definition at line 63 of file DeliveryContexts.java.

63  {
64  for(DeliveryContext dc : this) {
65  if(dc instanceof ValueContext) {
66  if(dc.match(value)) {
67  Product p = dc.getDeliveryProduct();
68  if(p != null) {
69  return p;
70  }
71  }
72  }
73  }
74  return null;
75  }
Here is the call graph for this function:

◆ getDeliveryStreets()

List<StreetItem> org.turro.financials.cart.delivery.DeliveryContexts.getDeliveryStreets ( String  search)

Definition at line 87 of file DeliveryContexts.java.

87  {
88  List<StreetItem> streets = new ArrayList<>();
89  for(DeliveryContext dc : this) {
90  if(dc instanceof StreetMapContext) {
91  streets.addAll(((StreetMapContext) dc).getStreets(search));
92  }
93  }
94  return streets;
95  }
Here is the caller graph for this function:

◆ getDeliveryValues()

Set<String> org.turro.financials.cart.delivery.DeliveryContexts.getDeliveryValues ( )

Definition at line 77 of file DeliveryContexts.java.

77  {
78  Set<String> values = new HashSet<>();
79  for(DeliveryContext dc : this) {
80  if(dc instanceof ValueContext) {
81  values.addAll(((ValueContext) dc).getValues());
82  }
83  }
84  return values;
85  }

◆ isStreetBased()

boolean org.turro.financials.cart.delivery.DeliveryContexts.isStreetBased ( )

Definition at line 97 of file DeliveryContexts.java.

97  {
98  return this.stream().anyMatch((dc) -> (dc instanceof StreetMapContext));
99  }

◆ readXML()

void org.turro.financials.cart.delivery.DeliveryContexts.readXML ( Element  root)

Definition at line 101 of file DeliveryContexts.java.

101  {
102  List<Element> children = root.getChildren("DeliveryByStreetMap");
103  for(Element el : children) {
104  add(new StreetMapContext(el.getAttributeValue("value"),
105  Long.valueOf(el.getAttributeValue("product")),
106  Long.valueOf(el.getAttributeValue("store")),
107  el.getAttributeValue("logistic")));
108  }
109  children = root.getChildren("DeliveryByZipcode");
110  for(Element el : children) {
111  add(new ZipcodeContext(el.getAttributeValue("value"),
112  Long.valueOf(el.getAttributeValue("product")),
113  Long.valueOf(el.getAttributeValue("store")),
114  el.getAttributeValue("logistic")));
115  }
116  children = root.getChildren("DeliveryByProvince");
117  for(Element el : children) {
118  add(new ProvinceContext(el.getAttributeValue("value"),
119  Long.valueOf(el.getAttributeValue("product")),
120  Long.valueOf(el.getAttributeValue("store")),
121  el.getAttributeValue("logistic")));
122  }
123  children = root.getChildren("DeliveryByValue");
124  for(Element el : children) {
125  add(new ValueContext(el.getAttributeValue("value"),
126  Long.valueOf(el.getAttributeValue("product")),
127  Long.valueOf(el.getAttributeValue("store")),
128  el.getAttributeValue("logistic")));
129  }
130  }

The documentation for this class was generated from the following file: