Skip to content

Commit 0183910

Browse files
Add Apple types and colours (#1697)
* add Apple types and colours
1 parent 27c9e22 commit 0183910

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ The list below is not complete and shows only a part of available providers. To
267267
* Ancient
268268
* Animal
269269
* App
270+
* Apple
270271
* Appliance
271272
* Aqua Teen Hunger Force
272273
* Artist
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package net.datafaker.providers.food;
2+
3+
import net.datafaker.providers.base.AbstractProvider;
4+
import net.datafaker.providers.base.BaseProviders;
5+
6+
/**
7+
* @since 2.5.3
8+
*/
9+
public class Apple extends AbstractProvider<BaseProviders> {
10+
11+
protected Apple(BaseProviders faker) {
12+
super(faker);
13+
}
14+
15+
public String type() {
16+
return resolve("apple.type");
17+
}
18+
19+
public String color() {
20+
return resolve("apple.color");
21+
}
22+
23+
}

src/main/java/net/datafaker/providers/food/FoodProviders.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import net.datafaker.providers.base.ProviderRegistration;
44

55
public interface FoodProviders extends ProviderRegistration {
6+
default Apple apple() {
7+
return getProvider(Apple.class, Apple::new);
8+
}
9+
610
default Beer beer() {
711
return getProvider(Beer.class, Beer::new);
812
}

src/main/java/net/datafaker/service/files/EnFile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public String getPath() {
3030
"ancient.yml",
3131
"animal.yml",
3232
"app.yml",
33+
"apple.yml",
3334
"appliance.yml",
3435
"aqua_teen_hunger_force.yml",
3536
"artist.yml",

src/main/resources/en/apple.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
en:
2+
faker:
3+
apple:
4+
type:
5+
- "Red Delicious"
6+
- "Fuji"
7+
- "Gala"
8+
- "Empire"
9+
- "Jonagold"
10+
- "Cortland"
11+
- "Granny Smith"
12+
- "Pippin"
13+
- "Crispin"
14+
- "Golden Delicious"
15+
- "Opal"
16+
- "Ginger Gold"
17+
- "Honeycrisp"
18+
- "Jazz"
19+
- "Ambrosia"
20+
- "Braeburn"
21+
- "Ashmead’s Kernel"
22+
- "Roxbury Russet"
23+
- "Spitzenburg"
24+
- "Baldwin"
25+
- "Pink Lady (Cripps Pink)"
26+
- "Lady Alice"
27+
- "Sweetango"
28+
- "Bramley"
29+
- "Rhode Island Greening"
30+
color:
31+
- "Red"
32+
- "Green"
33+
- "Yellow / Golden"
34+
- "Red + Green"
35+
- "Red + Yellow / Golden"
36+
- "Pink / Rosy shades"
37+
- "Striped / Blushed patterns"
38+
- "Russeted / Brownish"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package net.datafaker.providers.foods;
2+
3+
import net.datafaker.providers.food.Apple;
4+
5+
import java.util.Collection;
6+
import java.util.List;
7+
8+
public class AppleTest extends FoodFakerTest {
9+
10+
private final Apple apple = getFaker().apple();
11+
12+
@Override
13+
protected Collection<TestSpec> providerListTest() {
14+
return List.of(
15+
TestSpec.of(apple::type, "apple.type"),
16+
TestSpec.of(apple::color, "apple.color")
17+
);
18+
}
19+
}

0 commit comments

Comments
 (0)