Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add OscarMovie.java and OscarMovie.yml #717

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,15 @@
</plugin>
</plugins>
</pluginManagement>
</build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
4 changes: 4 additions & 0 deletions src/main/java/com/github/javafaker/Faker.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public class Faker {
private final Sip sip;
private final EnglandFootBall englandfootball;
private final Mountain mountain;
private final OscarMovie oscarMovie;

public Faker() {
this(Locale.ENGLISH);
Expand All @@ -132,6 +133,7 @@ public Faker(FakeValuesService fakeValuesService, RandomService random) {
this.randomService = random;
this.fakeValuesService = fakeValuesService;

this.oscarMovie = new OscarMovie(this);
this.ancient = new Ancient(this);
this.app = new App(this);
this.artist = new Artist(this);
Expand Down Expand Up @@ -691,6 +693,8 @@ public StarCraft starCraft() {

public Mountain mountain() { return mountain; }

public OscarMovie oscarMovie(){return oscarMovie;}

public String resolve(String key) {
return this.fakeValuesService.resolve(key, this, this);
}
Expand Down
96 changes: 96 additions & 0 deletions src/main/java/com/github/javafaker/OscarMovie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.github.javafaker;

/**
* This is the class generates random stream of Movie
* @author ak-maker
* */
public class OscarMovie {
/**
* The faker instance for generating random names of things.
*/
private final Faker faker;
/**
* The year instance is used for randomly choose the year (from 2013 to 2022)
*/
private final String year;
/**
* The choice instance eis used for randomly choose the the
* first/second/third movie of that year.
*/
private final String choice;
/**
* Part of the string to reslove
*/
private final String str;
/**
* This is the constructor initialize faker and two other
* variable for random generation.
* @param faker faker The Faker instance for generating random names of things.
*/
protected OscarMovie(final Faker faker) {
this.faker = faker;
this.year = this.faker.resolve("OscarMovie.year.years");
this.choice = this.faker.resolve("OscarMovie.year.choice");
this.str = "OscarMovie.".concat(year).concat(".").concat(choice);
}

/**
* @return year
*/
public String getYear(){
return year;
}

/**
* @return choice
*/
public String getChoice(){
return choice;
}

/**
* @return str
*/
public String getStr(){
return str;
}

/**
* This method generates random actor
* @return random actor from OscarMovie.yml
*/
public String actor() {
return faker.resolve(str.concat(".actor"));
}

/**
* This method generates random movieName
* @return random movieName from OscarMovie.yml
*/
public String movieName() {
return faker.resolve(str.concat(".movieName"));
}

/**
* This method generates random quote
* @return random quote from OscarMovie.yml
*/
public String quote() {
return faker.resolve(str.concat(".quote"));
}
/**
* This method generates random character
* @return random character from OscarMovie.yml
*/
public String character() {
return faker.resolve(str.concat(".character"));
}

/**
* This method enerates random releaseDate
* @return random releaseDate from OscarMovie.yml
*/
public String releaseDate() {
return faker.resolve(str.concat(".releaseDate"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public String getPath() {
}

private static List<String> FILES = Arrays.asList("address.yml",
"OscarMovie.yml",
"ancient.yml",
"animal.yml",
"app.yml",
Expand Down
Loading