forked from mongodb/docs-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
107 lines (83 loc) · 2.42 KB
/
Product.java
File metadata and controls
107 lines (83 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.mongodb.examples.springdatabulkinsert;
import net.datafaker.Faker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
import java.util.Random;
// start-products-class
@Document("products")
public class Product {
private static final Logger LOG = LoggerFactory
.getLogger(Products.class);
@Id
private String id;
private String name;
private int qty;
private double price;
private Date available;
private Date unavailable;
private String skuId;
public Product(String name, int qty, double price, Date available, Date unavailable, String skuId) {
this.name = name;
this.qty = qty;
this.price = price;
this.available = available;
this.unavailable = unavailable;
this.skuId = skuId;
}
public static Product [] RandomProducts( int count) {
Faker faker = new Faker();
Random rand = new Random();
Product [] retProds = new Product[count];
for (int i=0; i<count; ++i) {
Product p = new Product( faker.animal().name(),
1+rand.nextInt(998),
10.0+rand.nextInt(9999),
new Date(), new Date(),
faker.idNumber().valid());
retProds[i] = p;
}
return retProds;
}
// Getters and setters
}
// end-products-class
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public int getQty() {
// return qty;
// }
// public void setQty(int qty) {
// this.qty = qty;
// }
// public double getPrice() {
// return price;
// }
// public void setPrice(double price) {
// this.price = price;
// }
// public Date getAvailable() {
// return available;
// }
// public void setAvailable(Date available) {
// this.available = available;
// }
// public Date getUnavailable() {
// return unavailable;
// }
// public void setUnavailable(Date unavailable) {
// this.unavailable = unavailable;
// }
// public String getSkuId() {
// return skuId;
// }
// public void setSkuId(String skuId) {
// this.skuId = skuId;
// }
// }