-
Notifications
You must be signed in to change notification settings - Fork 863
Expand file tree
/
Copy pathCompany.java
More file actions
97 lines (79 loc) · 2.96 KB
/
Company.java
File metadata and controls
97 lines (79 loc) · 2.96 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
package com.github.javafaker;
import com.github.javafaker.service.FakerIDN;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import static org.apache.commons.lang3.StringUtils.join;
public class Company {
private final Faker faker;
protected Company(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("company.name", this, faker);
}
public String suffix() {
return faker.fakeValuesService().resolve("company.suffix", this, faker);
}
public String industry() {
return faker.fakeValuesService().resolve("company.industry", this, faker);
}
public String profession() {
return faker.fakeValuesService().resolve("company.profession", this, faker);
}
public String buzzword() {
@SuppressWarnings("unchecked")
List<List<String>> buzzwordLists = (List<List<String>>) faker.fakeValuesService().fetchObject("company.buzzwords");
List<String> buzzwords = new ArrayList<String>();
for (List<String> buzzwordList : buzzwordLists) {
buzzwords.addAll(buzzwordList);
}
return buzzwords.get(faker.random().nextInt(buzzwords.size()));
}
/**
* Generate a buzzword-laden catch phrase.
*/
public String catchPhrase() {
@SuppressWarnings("unchecked")
List<List<String>> catchPhraseLists = (List<List<String>>) faker.fakeValuesService().fetchObject("company.buzzwords");
return joinSampleOfEachList(catchPhraseLists, " ");
}
/**
* When a straight answer won't do, BS to the rescue!
*/
public String bs() {
@SuppressWarnings("unchecked")
List<List<String>> buzzwordLists = (List<List<String>>) faker.fakeValuesService().fetchObject("company.bs");
return joinSampleOfEachList(buzzwordLists, " ");
}
/**
* Generate a random company logo url in PNG format.
*/
public String logo() {
int number = faker.random().nextInt(13) + 1;
return "https://pigment.github.io/fake-logos/logos/medium/color/" + number + ".png";
}
public String url() {
return join(
"www",
".",
FakerIDN.toASCII(domainName()),
".",
domainSuffix()
);
}
private String domainName(){
return StringUtils.deleteWhitespace(name().toLowerCase(Locale.ROOT).replaceAll(",", "").replaceAll("'", ""));
}
private String domainSuffix() {
return faker.fakeValuesService().resolve("internet.domain_suffix", this, faker);
}
private String joinSampleOfEachList(List<List<String>> listOfLists, String separator) {
List<String> words = new ArrayList<String>();
for (List<String> list : listOfLists) {
words.add(list.get(faker.random().nextInt(list.size())));
}
return join(words, separator);
}
}