Compare commits

...

No commits in common. "master" and "travis" have entirely different histories.

448 changed files with 17 additions and 66455 deletions

View File

@ -1,25 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Code to reproduce
**Expected behavior**
A clear and concise description of what you expected to happen.
**Versions:**
- OS: [e.g. OSX]
- JDK
- Faker Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View File

@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

5
.gitignore vendored
View File

@ -4,7 +4,4 @@ target
.settings
.idea/
*.iml
.java-version
/dependency-reduced-pom.xml
META-INF/
bin/
.java-version

View File

@ -1,17 +1,16 @@
language: java
dist: xenial
jdk:
- openjdk10
- oraclejdk11
sudo: true
script: mvn verify failsafe:integration-test failsafe:verify
- oraclejdk7
- oraclejdk8
- openjdk7
- openjdk6
branches:
except:
- travis
- travis
notifications:
email: false
after_success:
- mvn clean cobertura:cobertura coveralls:report
- mvn clean cobertura:cobertura coveralls:cobertura
env:
global:
secure: GIdF3itH9owJXPEb/ri984853yRRIDeWbSZW7yMh6XOymGWAi0+3fGssBbHqjS/s3QgiDhnrKfDjF7UhHE1aeYCxgHM5QGOjfHUhOKevhUE4u0h4ysFS4wbh7zYODMzxdFpiKwdnNF+TvMctIReH5IVDu8gUxbNrcSXN6PQgvlM=
secure: BN4ubmSkpNY/nzaZO3zGiVK+9xhX/O5pWqFk7llUGaAmDw1dNiTrVWMdzaGxmAJa+v1US5vdwLx8ZQMlO6crp3T1VGOwEM2J5vFDPtyMsKM1hC6yKYnJhlfskNznJBhWJZKaLd6FgbxaW08C0BedocD9uVnsPKHiOHn2FXUm8Hs=

View File

@ -1,76 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at rickyyim AT gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

View File

@ -1,15 +0,0 @@
First and foremost thanks to anyone who contributes, very much appreciated.
## Guidelines
- Need to maintain compatibility with Java 1.6 (and Android). Therefore any attempt to migrate to 1.6 JDKs and above will not be merged back in.
- If you add new faker classes like `Address`, `Country`, and `Number` they should be accompanied by a unit test. Where relevant please add more assertions to the `com.github.javafaker.integration.FakerIT` class.
- If you add a new faker class, update the `README.md`.
- Submit a PR with your change and if there are no comments, changes will be merged in
- If you're not sure about the change, raise an issue and have a discussion before spending time coding it up
- Try and make one logical change per PR. That is not make many changes in one PR. Submit multiple PRs instead
## Building
- Should be as easy as running `mvn clean install` on the root directory

13
LICENSE
View File

@ -1,13 +0,0 @@
Copyright 2014 DiUS Computing
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

207
README.md
View File

@ -1,207 +0,0 @@
Java Faker
==========
[![Maven Status](https://maven-badges.herokuapp.com/maven-central/com.github.javafaker/javafaker/badge.svg?style=flat)](http://mvnrepository.com/artifact/com.github.javafaker/javafaker)
[![Build Status](https://travis-ci.org/DiUS/java-faker.svg?branch=master)](https://travis-ci.org/DiUS/java-faker)
[![Coverage Status](https://coveralls.io/repos/DiUS/java-faker/badge.svg)](https://coveralls.io/r/DiUS/java-faker)
[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
This library is a port of Ruby's [faker](https://github.com/stympy/faker) gem (as well as Perl's Data::Faker library) that generates fake data.
It's useful when you're developing a new project and need some pretty data for showcase.
Usage
-----
In pom.xml, add the following xml stanza between `<dependencies> ... </dependencies>`
```xml
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
</dependency>
```
For gradle users, add the following to your build.gradle file.
```groovy
dependencies {
implementation 'com.github.javafaker:javafaker:1.0.2'
}
```
In your Java code
```java
Faker faker = new Faker();
String name = faker.name().fullName(); // Miss Samanta Schmidt
String firstName = faker.name().firstName(); // Emory
String lastName = faker.name().lastName(); // Barton
String streetAddress = faker.address().streetAddress(); // 60018 Sawayn Brooks Suite 449
```
This is a [demo web application](https://java-faker.herokuapp.com/) that uses the library.
Javadoc
-----
http://dius.github.io/java-faker/apidocs/index.html
Contributions
-------------
See [CONTRIBUTING.md](https://github.com/DiUS/java-faker/blob/master/CONTRIBUTING.md)
Fakers
-----
* Address
* Ancient
* Animal
* App
* Aqua Teen Hunger Force
* Artist
* Avatar
* Back To The Future
* Aviation
* Basketball
* Beer
* Bojack Horseman
* Book
* Bool
* Business
* ChuckNorris
* Cat
* Code
* Coin
* Color
* Commerce
* Company
* Crypto
* DateAndTime
* Demographic
* Disease
* Dog
* DragonBall
* Dune
* Educator
* Esports
* EnglandFootBall
* File
* Finance
* Food
* Friends
* FunnyName
* GameOfThrones
* Gender
* Hacker
* HarryPotter
* Hipster
* HitchhikersGuideToTheGalaxy
* Hobbit
* HowIMetYourMother
* IdNumber
* Internet
* Job
* Kaamelott
* LeagueOfLegends
* Lebowski
* LordOfTheRings
* Lorem
* Matz
* Music
* Name
* Nation
* Number
* Options
* Overwatch
* PhoneNumber
* Photography
* Pokemon
* Princess Bride
* Relationship Terms
* RickAndMorty
* Robin
* RockBand
* Shakespeare
* Sip
* SlackEmoji
* Space
* StarCraft
* StarTrek
* Stock
* Superhero
* Team
* TwinPeaks
* University
* Weather
* Witcher
* Yoda
* Zelda
Usage with Locales
-----
```java
Faker faker = new Faker(new Locale("YOUR_LOCALE"));
```
Supported Locales
-----
* bg
* ca
* ca-CAT
* da-DK
* de
* de-AT
* de-CH
* en
* en-AU
* en-au-ocker
* en-BORK
* en-CA
* en-GB
* en-IND
* en-MS
* en-NEP
* en-NG
* en-NZ
* en-PAK
* en-SG
* en-UG
* en-US
* en-ZA
* es
* es-MX
* fa
* fi-FI
* fr
* he
* hu
* in-ID
* it
* ja
* ko
* nb-NO
* nl
* pl
* pt
* pt-BR
* ru
* sk
* sv
* sv-SE
* tr
* uk
* vi
* zh-CN
* zh-TW
TODO
----
- Port more classes over as there are more entries in the yml file that we don't have classes for
LICENSE
-------
Copyright (c) 2019 DiUS Computing Pty Ltd. See the LICENSE file for license rights and limitations.

152
pom.xml
View File

@ -1,152 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<packaging>jar</packaging>
<version>1.0.3-SNAPSHOT</version>
<name>Java Faker</name>
<description>
This library is a port of Ruby's stympy/faker gem (as well as Perl's Data::Faker library) that generates fake data.
It's useful when you're developing a new project and need some pretty data for showcase.
</description>
<url>http://github.com/DiUS/java-faker</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/DiUS/java-faker.git</connection>
<developerConnection>scm:git:git@github.com:DiUS/java-faker.git</developerConnection>
<url>git://github.com/DiUS/java-faker.git</url>
</scm>
<developers>
<developer>
<id>renshao</id>
<name>Ren Shao</name>
<email>renshao@gmail.com</email>
</developer>
<developer>
<id>codingricky</id>
<name>Ricky Yim</name>
</developer>
</developers>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.26</version>
<classifier>android</classifier>
</dependency>
<dependency>
<groupId>com.github.mifmif</groupId>
<artifactId>generex</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.6</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<repoToken>${env.COVERALLS_TOKEN}</repoToken>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<format>xml</format>
<maxmem>256m</maxmem>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>failsafe-maven-plugin</artifactId>
<version>2.4.3-alpha-1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

9
settings.xml Normal file
View File

@ -0,0 +1,9 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
</servers>
</settings>

View File

@ -1,117 +0,0 @@
package com.github.javafaker;
public class Address {
private final Faker faker;
protected Address(Faker faker) {
this.faker = faker;
}
public String streetName() {
return faker.fakeValuesService().resolve("address.street_name", this, faker);
}
public String streetAddressNumber() {
return String.valueOf(faker.random().nextInt(1000));
}
public String streetAddress() {
return faker.fakeValuesService().resolve("address.street_address", this, faker);
}
public String streetAddress(boolean includeSecondary) {
String streetAddress = faker.fakeValuesService().resolve("address.street_address", this, faker);
if (includeSecondary) {
streetAddress = streetAddress + " " + secondaryAddress();
}
return streetAddress;
}
public String secondaryAddress() {
return faker.numerify(faker.fakeValuesService().resolve("address.secondary_address", this,faker));
}
public String zipCode() {
return faker.bothify(faker.fakeValuesService().resolve("address.postcode", this,faker));
}
public String postcode() {
return faker.bothify(faker.fakeValuesService().resolve("address.postcode", this,faker));
}
public String zipCodeByState(String stateAbbr) {
return faker.fakeValuesService().resolve("address.postcode_by_state." + stateAbbr, this, faker);
}
public String countyByZipCode(String postCode) {
return faker.fakeValuesService().resolve("address.county_by_postcode." + postCode, this, faker);
}
public String streetSuffix() {
return faker.fakeValuesService().resolve("address.street_suffix", this, faker);
}
public String streetPrefix() {
return faker.fakeValuesService().resolve("address.street_prefix", this, faker);
}
public String citySuffix() {
return faker.fakeValuesService().resolve("address.city_suffix", this, faker);
}
public String cityPrefix() {
return faker.fakeValuesService().resolve("address.city_prefix", this, faker);
}
public String city() {
return faker.fakeValuesService().resolve("address.city", this, faker);
}
public String cityName() {
return faker.fakeValuesService().resolve("address.city_name", this, faker);
}
public String state() {
return faker.fakeValuesService().resolve("address.state", this, faker);
}
public String stateAbbr() {
return faker.fakeValuesService().resolve("address.state_abbr", this, faker);
}
public String firstName() {
return faker.name().firstName();
}
public String lastName() {
return faker.name().lastName();
}
public String latitude() {
return String.format("%.8g", (faker.random().nextDouble() * 180) - 90);
}
public String longitude() {
return String.format("%.8g", (faker.random().nextDouble() * 360) - 180);
}
public String timeZone() {
return faker.fakeValuesService().resolve("address.time_zone", this, faker);
}
public String country() {
return faker.fakeValuesService().resolve("address.country", this, faker);
}
public String countryCode() {
return faker.fakeValuesService().resolve("address.country_code", this, faker);
}
public String buildingNumber() {
return faker.numerify(faker.fakeValuesService().resolve("address.building_number", this, faker));
}
public String fullAddress() {
return faker.fakeValuesService().resolve("address.full_address", this, faker);
}
}

View File

@ -1,26 +0,0 @@
package com.github.javafaker;
public class Ancient {
private final Faker faker;
protected Ancient(Faker faker) {
this.faker = faker;
}
public String god() {
return faker.resolve("ancient.god");
}
public String primordial() {
return faker.resolve("ancient.primordial");
}
public String titan() {
return faker.resolve("ancient.titan");
}
public String hero() {
return faker.resolve("ancient.hero");
}
}

View File

@ -1,13 +0,0 @@
package com.github.javafaker;
public class Animal {
private final Faker faker;
protected Animal(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("creature.animal.name", this, faker);
}
}

View File

@ -1,21 +0,0 @@
package com.github.javafaker;
public class App {
private final Faker faker;
protected App(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("app.name", this, faker);
}
public String version() {
return faker.numerify(faker.fakeValuesService().resolve("app.version", this, faker));
}
public String author() {
return faker.fakeValuesService().resolve("app.author", this, faker);
}
}

View File

@ -1,15 +0,0 @@
package com.github.javafaker;
public class AquaTeenHungerForce {
private final Faker faker;
protected AquaTeenHungerForce(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.fakeValuesService().resolve("aqua_teen_hunger_force.character", this, faker);
}
}

View File

@ -1,14 +0,0 @@
package com.github.javafaker;
public class Artist {
private final Faker faker;
protected Artist(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().fetchString("artist.names");
}
}

View File

@ -1,15 +0,0 @@
package com.github.javafaker;
public class Avatar {
private final Faker faker;
private final String baseUrl;
protected Avatar(Faker faker) {
this.faker = faker;
this.baseUrl = "https://s3.amazonaws.com/uifaces/faces/twitter/";
}
public String image() {
return baseUrl + faker.fakeValuesService().resolve("internet.avatar", this, faker);
}
}

View File

@ -1,36 +0,0 @@
package com.github.javafaker;
/**
* Generates aviation related strings.
*/
public class Aviation {
private final Faker faker;
protected Aviation(Faker faker) {
this.faker = faker;
}
/**
* @return some aircraft name/model/make e.g. "An-2".
*/
public String aircraft() {
return faker.fakeValuesService().fetchString("aviation.aircraft");
}
/**
* Returns an airport ICAO code.
* See also: https://en.wikipedia.org/wiki/List_of_airports_by_ICAO_code:_A
*/
public String airport() {
return faker.fakeValuesService().fetchString("aviation.airport");
}
/**
* Provides a METAR weather report.
* Have a look at https://en.wikipedia.org/wiki/METAR
*/
public String METAR() {
return faker.fakeValuesService().fetchString("aviation.metar");
}
}

View File

@ -1,21 +0,0 @@
package com.github.javafaker;
public class BackToTheFuture {
private final Faker faker;
protected BackToTheFuture(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.resolve("back_to_the_future.characters");
}
public String date() {
return faker.resolve("back_to_the_future.dates");
}
public String quote() {
return faker.resolve("back_to_the_future.quotes");
}
}

View File

@ -1,22 +0,0 @@
package com.github.javafaker;
public class Barcode {
private Faker faker;
public Barcode(Faker faker) {
this.faker = faker;
}
public String type() {
return faker.resolve("barcode.types");
}
public String data(){
return faker.resolve("barcode.datas");
}
public String typeAndData(){
return faker.resolve("barcode.typeAndData");
}
}

View File

@ -1,49 +0,0 @@
package com.github.javafaker;
/**
* Generate random components of basketall game, e.g. teams, coaches, positions and players.
* @author unknown and irakatz
*/
public class Basketball {
private final Faker faker;
/**
* Create a constructor for Basketball.
* @param faker The Faker instance for generating random, different kinds of disease, e.g. the internal disease.
*/
protected Basketball(Faker faker) {
this.faker = faker;
}
/**
* Generate random basketball teams
* @return Basketball teams
*/
public String teams() {
return faker.fakeValuesService().resolve("basketball.teams", this, faker);
}
/**
* Generate random coaches in basketball game
* @return Basketball coaches
*/
public String coaches() {
return faker.fakeValuesService().resolve("basketball.coaches", this, faker);
}
/**
* Generate random positions in basketball game
* @return Basketball positions
*/
public String positions() {
return faker.fakeValuesService().resolve("basketball.positions", this, faker);
}
/**
* Generate random basketball players
* @return Basketball players
*/
public String players() {
return faker.fakeValuesService().resolve("basketball.players", this, faker);
}
}

View File

@ -1,29 +0,0 @@
package com.github.javafaker;
public class Beer {
private final Faker faker;
protected Beer(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("beer.name", this, faker);
}
public String style() {
return faker.fakeValuesService().resolve("beer.style", this, faker);
}
public String hop() {
return faker.fakeValuesService().resolve("beer.hop", this, faker);
}
public String yeast() {
return faker.fakeValuesService().resolve("beer.yeast", this, faker);
}
public String malt() {
return faker.fakeValuesService().resolve("beer.malt", this, faker);
}
}

View File

@ -1,43 +0,0 @@
package com.github.javafaker;
/**
* Generate random parts in BojackHorseman.
* @author unknown and irakatz
*/
public class BojackHorseman {
private final Faker faker;
/**
* Create a constructor for BojackHorseman.
* @param faker The Faker instance for generating random parts in BojackHorseman.
*/
protected BojackHorseman(Faker faker) {
this.faker = faker;
}
/**
* Generate random character's name in BojackHorseman.
* @return Characters in BojackHorseman
*/
public String characters() {
return faker.fakeValuesService().resolve("bojack_horseman.characters", this, faker);
}
/**
* Generate random quotes in BojackHorseman.
* @return Quotes in BojackHorseman
*/
public String quotes() {
return faker.fakeValuesService().resolve("bojack_horseman.quotes", this, faker);
}
/**
* Generate random tongue twisters in BojackHorseman.
* @return Tongue twisters in BojackHorseman
*/
public String tongueTwisters() {
return faker.fakeValuesService().resolve("bojack_horseman.tongue_twisters", this, faker);
}
}

View File

@ -1,25 +0,0 @@
package com.github.javafaker;
public class Book {
private final Faker faker;
protected Book(Faker faker) {
this.faker = faker;
}
public String author() {
return faker.fakeValuesService().resolve("book.author", this, faker);
}
public String title() {
return faker.fakeValuesService().resolve("book.title", this, faker);
}
public String publisher() {
return faker.fakeValuesService().resolve("book.publisher", this, faker);
}
public String genre() {
return faker.fakeValuesService().resolve("book.genre", this, faker);
}
}

View File

@ -1,13 +0,0 @@
package com.github.javafaker;
public class Bool {
private final Faker faker;
protected Bool(Faker faker) {
this.faker = faker;
}
public boolean bool() {
return faker.random().nextBoolean();
}
}

View File

@ -1,30 +0,0 @@
package com.github.javafaker;
public class Buffy {
private final Faker faker;
protected Buffy(Faker faker) {
this.faker = faker;
}
public String characters() {
return faker.fakeValuesService().resolve("buffy.characters", this, faker);
}
public String quotes() {
return faker.fakeValuesService().resolve("buffy.quotes", this, faker);
}
public String celebrities() {
return faker.fakeValuesService().resolve("buffy.celebrities", this, faker);
}
public String bigBads() {
return faker.fakeValuesService().resolve("buffy.big_bads", this, faker);
}
public String episodes() {
return faker.fakeValuesService().resolve("buffy.episodes", this, faker);
}
}

View File

@ -1,22 +0,0 @@
package com.github.javafaker;
public class Business {
private final Faker faker;
protected Business(Faker faker) {
this.faker = faker;
}
public String creditCardNumber() {
return faker.fakeValuesService().resolve("business.credit_card_numbers", this, faker);
}
public String creditCardType() {
return faker.fakeValuesService().resolve("business.credit_card_types", this, faker);
}
public String creditCardExpiry() {
return faker.fakeValuesService().resolve("business.credit_card_expiry_dates", this, faker);
}
}

View File

@ -1,22 +0,0 @@
package com.github.javafaker;
public class Cat {
private final Faker faker;
protected Cat(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("creature.cat.name", this, faker);
}
public String breed() {
return faker.fakeValuesService().resolve("creature.cat.breed", this, faker);
}
public String registry() {
return faker.fakeValuesService().resolve("creature.cat.registry", this, faker);
}
}

View File

@ -1,13 +0,0 @@
package com.github.javafaker;
public class ChuckNorris {
private final Faker faker;
protected ChuckNorris(Faker faker) {
this.faker = faker;
}
public String fact() {
return faker.fakeValuesService().resolve("chuck_norris.fact", this, faker);
}
}

View File

@ -1,230 +0,0 @@
package com.github.javafaker;
import org.apache.commons.lang3.ArrayUtils;
import static org.apache.commons.lang3.math.NumberUtils.toInt;
/**
* ISBN Rules : https://en.wikipedia.org/wiki/International_Standard_Book_Number
*/
public class Code {
private final Faker faker;
protected Code(Faker faker) {
this.faker = faker;
}
/**
* This can be overridden by specifying
* <code>
* code:
* isbn_gs1: "some expression"
* </code>
* in the appropriate yml file.
* @return a GS1 code for an ISBN13, currently is only 978 and 979
*/
public String isbnGs1() {
return faker.regexify("978|979");
}
/**
* This can be overridden by specifying
* <code>
* code:
* isbn_group: "some expression"
* </code>
* in the appropriate yml file.
* @return an ISBN group number
*/
public String isbnGroup() {
return faker.regexify("[0-1]");
}
/**
* This can be overridden by specifying
* <code>
* code:
* isbn_registrant: "some expression"
* </code>
* in the appropriate yml file.
* @return an ISBN registrant 'element' with separator
*/
public String isbnRegistrant() {
int ct = faker.random().nextInt(6) + 1;
switch (ct) {
case 6:
return faker.number().numberBetween(0,1) + faker.number().digit() + "-" + faker.number().digits(6);
case 5:
return faker.number().numberBetween(200,699) + "-" + faker.number().digits(5);
case 4:
return faker.number().numberBetween(7000,8499) + "-" + faker.number().digits(4);
case 3:
return faker.number().numberBetween(85000,89999) + "-" + faker.number().digits(3);
case 2:
return faker.number().numberBetween(900000,949999) + "-" + faker.number().digits(2);
case 1:
return faker.number().numberBetween(9500000,9999999) + "-" + faker.number().digits(1);
default:
throw new IllegalStateException("Invalid random " + ct);
}
}
/**
* @return a valid ISBN10 number with no separators (ex. 9604250590)
*/
public String isbn10() {
return isbn10(false);
}
/**
* @param separator true if you want separators returned, false otherwise
* @return a valid ISBN10 number with or without separators (ex. 9604250590, 960-425-059-0)
*/
public String isbn10(boolean separator) {
// The registration group identifier is a 1- to 5-digit number
final StringBuilder isbn10 = new StringBuilder()
.append(faker.expression("#{code.isbn_group}"))
.append('-')
.append(faker.expression("#{code.isbn_registrant}"))
.append('-');
final int checkDigit = isbn10CheckDigit(isbn10);
isbn10.append(checkDigit != 10 ? checkDigit : "X");
return separator ? isbn10.toString() : stripIsbnSeparator(isbn10);
}
/**
* @return a valid ISBN13 number with no separators (ex. 9789604250590)
*/
public String isbn13() {
return isbn13(false);
}
/**
* @param separator true if you want separators returned, false otherwise
* @return a valid ISBN13 number with or without separators (ex. 9789604250590, 978-960-425-059-0)
*/
public String isbn13(boolean separator) {
// The registration group identifier is a 1- to 5-digit number
final StringBuilder isbn13 = new StringBuilder()
.append(faker.expression("#{code.isbn_gs1}"))
.append('-')
.append(faker.expression("#{code.isbn_group}"))
.append('-')
.append(faker.expression("#{code.isbn_registrant}"))
.append('-');
final int checkDigit = isbn13CheckDigit(isbn13);
isbn13.append(checkDigit);
return separator ? isbn13.toString() : stripIsbnSeparator(isbn13);
}
private final int isbn10CheckDigit(CharSequence t) {
String value = stripIsbnSeparator(t);
int sum = 0;
for (int i = 0; i < value.length(); i++) {
sum += ((i + 1) * toInt(value.substring(i, i + 1)));
}
return sum % 11;
}
private final int isbn13CheckDigit(CharSequence t) {
String value = stripIsbnSeparator(t);
int sum = 0;
int multiplier = 0;
for (int i = 0; i < value.length(); i++) {
multiplier = i % 2 == 0 ? 1 : 3;
sum += multiplier * toInt(value.subSequence(i, i + 1).toString());
}
return (10 - sum % 10) % 10;
}
private final String stripIsbnSeparator(CharSequence t) {
return t.toString().replaceAll("-","");
}
public String asin() {
return faker.resolve("code.asin");
}
public String imei() {
char[] str = new char[15];
int len = str.length;
// Fill in the first two values of the string based with the specified prefix.
String arr = faker.options().option(REPORTING_BODY_IDENTIFIERS);
str[0] = arr.charAt(0);
str[1] = arr.charAt(1);
// Fill all the remaining numbers except for the last one with random values.
for (int i=2; i < len - 1; i++) {
str[i] = Character.forDigit(faker.number().numberBetween(0, 9), 10);
}
// Calculate the Luhn checksum of the values thus far
int lenOffset = (len + 1) % 2;
int t = 0;
int sum = 0;
for (int i = 0; i < len - 1; i++) {
if ((i + lenOffset) % 2 != 0) {
t = Character.getNumericValue(str[i]) * 2;
if (t > 9) {
t -= 9;
}
sum += t;
} else {
sum += Character.getNumericValue(str[i]);
}
}
// Choose the last digit so that it causes the entire string to pass the checksum.
str[len - 1] = Character.forDigit(((10 - (sum % 10)) % 10), 10);
return new String(str);
}
private static final String [] REPORTING_BODY_IDENTIFIERS
= {"01", "10", "30", "33", "35", "44", "45", "49", "50", "51", "52", "53", "54", "86", "91", "98", "99"};
public String ean8() {
return gtin8();
}
public String gtin8() {
char[] values = faker.regexify("\\d{7}").toCharArray();
int sum = 0;
for (int i = 0; i < values.length; i++) {
sum += Character.getNumericValue(values[i]) * GTIN_8_CHECK_DIGITS[i];
}
int checkDigit = 10 - sum % 10;
if (checkDigit == 10) {
return new String(ArrayUtils.add(values, Character.forDigit(0, 10)));
} else {
return new String(ArrayUtils.add(values, Character.forDigit(checkDigit, 10)));
}
}
public String ean13() {
return gtin13();
}
public String gtin13() {
char[] values = faker.regexify("\\d{12}").toCharArray();
int sum = 0;
for (int i = 0; i < values.length; i++) {
sum += Character.getNumericValue(values[i]) * GTIN_13_CHECK_DIGITS[i];
}
int checkDigit = 10 - sum % 10;
if (checkDigit == 10) {
return new String(ArrayUtils.add(values, Character.forDigit(0, 10)));
} else {
return new String(ArrayUtils.add(values, Character.forDigit(checkDigit, 10)));
}
}
private static final int[] GTIN_8_CHECK_DIGITS = { 3, 1, 3, 1, 3, 1, 3 };
private static final int[] GTIN_13_CHECK_DIGITS = { 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3 };
}

View File

@ -1,17 +0,0 @@
package com.github.javafaker;
public class Coin {
private final Faker faker;
protected Coin(Faker faker) {
this.faker = faker;
}
/**
* @return coin side e.g. "Heads", "Tails".
*/
public String flip() {
return faker.fakeValuesService().resolve("coin.flip", this, faker);
}
}

View File

@ -1,24 +0,0 @@
package com.github.javafaker;
public class Color {
private final Faker faker;
protected Color(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("color.name", this, faker);
}
public String hex() {
return hex(true);
}
public String hex(boolean includeHashSign) {
String hexString = faker.random().hex(6);
if(includeHashSign)
return "#" + hexString;
return hexString;
}
}

View File

@ -1,66 +0,0 @@
package com.github.javafaker;
import org.apache.commons.lang3.StringUtils;
import java.text.DecimalFormat;
import java.util.SortedSet;
import java.util.TreeSet;
public class Commerce {
private final Faker faker;
protected Commerce(Faker faker) {
this.faker = faker;
}
public String color() {
return faker.fakeValuesService().resolve("color.name", this, faker);
}
public String department() {
int numberOfDepartments = Math.max(faker.random().nextInt(4), 1);
SortedSet<String> departments = new TreeSet<String>();
while (departments.size() < numberOfDepartments) {
departments.add(faker.fakeValuesService().resolve("commerce.department", this, faker));
}
if (departments.size() > 1) {
String lastDepartment = departments.last();
return StringUtils.join(departments.headSet(lastDepartment), ", ") + " & " + lastDepartment;
} else {
return departments.first();
}
}
public String productName() {
return StringUtils.join(new String[] {
faker.fakeValuesService().resolve("commerce.product_name.adjective", this,faker),
faker.fakeValuesService().resolve("commerce.product_name.material", this, faker),
faker.fakeValuesService().resolve("commerce.product_name.product", this, faker) }, " ");
}
public String material() {
return faker.fakeValuesService().resolve("commerce.product_name.material", this, faker);
}
/**
* Generate a random price between 0.00 and 100.00
*/
public String price() {
return price(0, 100);
}
public String price(double min, double max) {
double price = min + (faker.random().nextDouble() * (max - min));
return new DecimalFormat("#0.00").format(price);
}
public String promotionCode() {
return promotionCode(6);
}
public String promotionCode(int digits) {
return StringUtils.join(faker.resolve("commerce.promotion_code.adjective"),
faker.resolve("commerce.promotion_code.noun"),
faker.number().digits(digits));
}
}

View File

@ -1,96 +0,0 @@
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 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().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);
}
}

View File

@ -1,40 +0,0 @@
package com.github.javafaker;
public class Country {
private final Faker faker;
private final String flagUrl;
protected Country(Faker faker) {
this.faker = faker;
this.flagUrl = "http://flags.fmcdn.net/data/flags/w580/";
}
public String flag() {
return flagUrl + faker.fakeValuesService().resolve("country.code2", this, faker) + ".png";
}
public String countryCode2() {
return faker.fakeValuesService().resolve("country.code2", this, faker);
}
public String countryCode3() {
return faker.fakeValuesService().resolve("country.code3", this, faker);
}
public String capital() {
return faker.fakeValuesService().resolve("country.capital", this, faker);
}
public String currency() {
return faker.fakeValuesService().resolve("country.currency", this, faker);
}
public String currencyCode() {
return faker.fakeValuesService().resolve("country.currency_code", this, faker);
}
public String name() {
return faker.fakeValuesService().resolve("country.name", this, faker);
}
}

View File

@ -1,15 +0,0 @@
package com.github.javafaker;
public enum CreditCardType {
VISA,
MASTERCARD,
DISCOVER,
AMERICAN_EXPRESS,
DINERS_CLUB,
JCB,
SWITCH,
SOLO,
DANKORT,
FORBRUGSFORENINGEN,
LASER
}

View File

@ -1,41 +0,0 @@
package com.github.javafaker;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Crypto {
private final Faker faker;
protected Crypto(Faker faker) {
this.faker = faker;
}
public String md5() {
return generateString("MD5");
}
public String sha1() {
return generateString("SHA-1");
}
public String sha256() {
return generateString("SHA-256");
}
public String sha512() {
return generateString("SHA-512");
}
private String generateString(String algorithm) {
try {
MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
String characters = faker.lorem().characters();
messageDigest.update(characters.getBytes(), 0, characters.length());
return new BigInteger(1, messageDigest.digest()).toString(16);
} catch (NoSuchAlgorithmException noSuchAlgorithmException) {
throw new RuntimeException(noSuchAlgorithmException);
}
}
}

View File

@ -1,18 +0,0 @@
package com.github.javafaker;
public class Currency {
private final Faker faker;
public Currency(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("currency.name", this, faker);
}
public String code() {
return faker.fakeValuesService().resolve("currency.code", this, faker);
}
}

View File

@ -1,185 +0,0 @@
/**
*
*/
package com.github.javafaker;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.concurrent.TimeUnit;
/**
* A generator of random dates.
*
* @author pmiklos
*
*/
public class DateAndTime {
private static final int DEFAULT_MIN_AGE = 18;
private static final int DEFAULT_MAX_AGE = 65;
private final Faker faker;
protected DateAndTime(Faker faker) {
this.faker = faker;
}
/**
* Generates a future date from now. Note that there is a 1 second slack to avoid generating a past date.
*
* @param atMost
* at most this amount of time ahead from now exclusive.
* @param unit
* the time unit.
* @return a future date from now.
*/
public Date future(int atMost, TimeUnit unit) {
Date now = new Date();
Date aBitLaterThanNow = new Date(now.getTime() + 1000);
return future(atMost, unit, aBitLaterThanNow);
}
/**
* Generates a future date from now, with a minimum time.
*
* @param atMost
* at most this amount of time ahead from now exclusive.
* @param minimum
* the minimum amount of time in the future from now.
* @param unit
* the time unit.
* @return a future date from now.
*/
public Date future(int atMost, int minimum, TimeUnit unit) {
Date now = new Date();
Date minimumDate = new Date(now.getTime() + unit.toMillis(minimum));
return future(atMost - minimum, unit, minimumDate);
}
/**
* Generates a future date relative to the {@code referenceDate}.
*
* @param atMost
* at most this amount of time ahead to the {@code referenceDate} exclusive.
* @param unit
* the time unit.
* @param referenceDate
* the future date relative to this date.
* @return a future date relative to {@code referenceDate}.
*/
public Date future(int atMost, TimeUnit unit, Date referenceDate) {
long upperBound = unit.toMillis(atMost);
long futureMillis = referenceDate.getTime();
futureMillis += 1 + faker.random().nextLong(upperBound - 1);
return new Date(futureMillis);
}
/**
* Generates a past date from now. Note that there is a 1 second slack added.
*
* @param atMost
* at most this amount of time earlier from now exclusive.
* @param unit
* the time unit.
* @return a past date from now.
*/
public Date past(int atMost, TimeUnit unit) {
Date now = new Date();
Date aBitEarlierThanNow = new Date(now.getTime() - 1000);
return past(atMost, unit, aBitEarlierThanNow);
}
/**
* Generates a past date from now, with a minimum time.
*
* @param atMost
* at most this amount of time earlier from now exclusive.
* @param minimum
* the minimum amount of time in the past from now.
* @param unit
* the time unit.
* @return a past date from now.
*/
public Date past(int atMost, int minimum, TimeUnit unit) {
Date now = new Date();
Date minimumDate = new Date(now.getTime() - unit.toMillis(minimum));
return past(atMost - minimum, unit, minimumDate);
}
/**
* Generates a past date relative to the {@code referenceDate}.
*
* @param atMost
* at most this amount of time past to the {@code referenceDate} exclusive.
* @param unit
* the time unit.
* @param referenceDate
* the past date relative to this date.
* @return a past date relative to {@code referenceDate}.
*/
public Date past(int atMost, TimeUnit unit, Date referenceDate) {
long upperBound = unit.toMillis(atMost);
long futureMillis = referenceDate.getTime();
futureMillis -= 1 + faker.random().nextLong(upperBound - 1);
return new Date(futureMillis);
}
/**
* Generates a random date between two dates.
*
* @param from
* the lower bound inclusive
* @param to
* the upper bound exclusive
* @return a random date between {@code from} and {@code to}.
* @throws IllegalArgumentException
* if the {@code to} date represents an earlier date than {@code from} date.
*/
public Date between(Date from, Date to) throws IllegalArgumentException {
if (to.before(from)) {
throw new IllegalArgumentException("Invalid date range, the upper bound date is before the lower bound.");
}
if (from.equals(to)) {
return from;
}
long offsetMillis = faker.random().nextLong(to.getTime() - from.getTime());
return new Date(from.getTime() + offsetMillis);
}
/**
* Generates a random birthday between 65 and 18 years ago from now.
*
* @return a random birthday between 65 and 18 years ago from now.
*/
public Date birthday() {
return birthday(DEFAULT_MIN_AGE, DEFAULT_MAX_AGE);
}
/**
* Generates a random birthday between two ages from now.
*
* @param minAge
* the minimal age
* @param maxAge
* the maximal age
* @return a random birthday between {@code minAge} and {@code maxAge} years ago from now.
* @throws IllegalArgumentException
* if the {@code maxAge} is lower than {@code minAge}.
*/
public Date birthday(int minAge, int maxAge) {
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
int currentMonth = Calendar.getInstance().get(Calendar.MONTH);
int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
Calendar from = new GregorianCalendar(currentYear - maxAge, currentMonth, currentDay);
Calendar to = new GregorianCalendar(currentYear - minAge, currentMonth, currentDay);
return between(from.getTime(), to.getTime());
}
}

View File

@ -1,30 +0,0 @@
package com.github.javafaker;
public class Demographic {
private final Faker faker;
protected Demographic(Faker faker) {
this.faker = faker;
}
public String race() {
return faker.fakeValuesService().fetchString("demographic.race");
}
public String educationalAttainment() {
return faker.fakeValuesService().fetchString("demographic.educational_attainment");
}
public String demonym() {
return faker.fakeValuesService().fetchString("demographic.demonym");
}
public String sex() {
return faker.fakeValuesService().fetchString("demographic.sex");
}
public String maritalStatus() {
return faker.fakeValuesService().fetchString("demographic.marital_status");
}
}

View File

@ -1,73 +0,0 @@
package com.github.javafaker;
/**
* Generate random, different kinds of disease.
*/
public class Disease {
private final Faker faker;
/**
* Create a constructor for Disease
* @param faker The Faker instance for generating random, different kinds of disease, e.g. the internal disease.
*/
protected Disease(Faker faker) {
this.faker = faker;
}
/**
* Generate random internal disease
* @return An internal disease
*/
public String internalDisease() {
return faker.fakeValuesService().resolve("disease.internal_disease", this, faker);
}
/**
* Generate random neurology disease
* @return A neurology disease
*/
public String neurology() {
return faker.fakeValuesService().resolve("disease.neurology", this, faker);
}
/**
* Generate random surgery disease
* @return A surgery disease
*/
public String surgery() {
return faker.fakeValuesService().resolve("disease.surgery", this, faker);
}
/**
* Generate random paediattics disease
* @return A paediatrics disease
*/
public String paediatrics() {
return faker.fakeValuesService().resolve("disease.paediatrics", this, faker);
}
/**
* Generate random gynecology and obstetrics disease
* @return A gynecology and obstetrics disease
*/
public String gynecologyAndObstetrics() {
return faker.fakeValuesService().resolve("disease.gynecology_and_obstetrics", this, faker);
}
/**
* Generate random ophthalmology and otorhinolaryngology disease
* @return A ophthalmology and otorhinolaryngology disease
*/
public String ophthalmologyAndOtorhinolaryngology() {
return faker.fakeValuesService().resolve("disease.ophthalmology_and_otorhinolaryngology", this, faker);
}
/**
* Generate random dermatolory disease
* @return A dermatolory disease
*/
public String dermatolory() {
return faker.fakeValuesService().resolve("disease.dermatolory", this, faker);
}
}

View File

@ -1,42 +0,0 @@
package com.github.javafaker;
public class Dog {
private final Faker faker;
protected Dog(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("creature.dog.name", this, faker);
}
public String breed() {
return faker.fakeValuesService().resolve("creature.dog.breed", this, faker);
}
public String sound() {
return faker.fakeValuesService().resolve("creature.dog.sound", this, faker);
}
public String memePhrase() {
return faker.fakeValuesService().resolve("creature.dog.meme_phrase", this, faker);
}
public String age() {
return faker.fakeValuesService().resolve("creature.dog.age", this, faker);
}
public String coatLength() {
return faker.fakeValuesService().resolve("creature.dog.coat_length", this, faker);
}
public String gender() {
return faker.fakeValuesService().resolve("creature.dog.gender", this, faker);
}
public String size() {
return faker.fakeValuesService().resolve("creature.dog.size", this, faker);
}
}

View File

@ -1,13 +0,0 @@
package com.github.javafaker;
public class DragonBall {
private final Faker faker;
protected DragonBall(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.fakeValuesService().resolve("dragon_ball.characters", this, faker);
}
}

View File

@ -1,80 +0,0 @@
package com.github.javafaker;
public class Dune {
private final Faker faker;
protected Dune(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.fakeValuesService().resolve("dune.characters", this, faker);
}
public String title() {
return faker.fakeValuesService().resolve("dune.titles", this, faker);
}
public String planet() {
return faker.fakeValuesService().resolve("dune.planets", this, faker);
}
public String quote() {
return quote(faker.options().option(Dune.Quote.class));
}
public String quote(Quote quote) {
return faker.fakeValuesService().resolve("dune.quotes." + quote.yamlKey, this, faker);
}
public String saying() {
return saying(faker.options().option(Dune.Saying.class));
}
public String saying(Saying saying) {
return faker.fakeValuesService().resolve("dune.sayings." + saying.yamlKey, this, faker);
}
public enum Quote {
GUILD_NAIVGATOR("guild_navigator"),
EMPEROR("emperor"),
PAUL("paul"),
THUFIR("thufir"),
JESSICA("jessica"),
IRULAN("irulan"),
MOHIAM("mohiam"),
GURNEY("gurney"),
LETO("leto"),
STILGAR("stilgar"),
LIET_KYNES("liet_kynes"),
PARDOT_KYNES("pardot_kynes"),
BARON_HARKONNEN("baron_harkonnen"),
PITER("piter"),
ALIA("alia"),
MAPES("mapes"),
DUNCAN("duncan"),
YUEH("yueh");
private final String yamlKey;
Quote(String yamlKey) {
this.yamlKey = yamlKey;
}
}
public enum Saying {
BENE_GESSERIT("bene_gesserit"),
FREMEN("fremen"),
MENTAT("mentat"),
MUADDIB("muaddib"),
ORANGE_CATHOLIC_BIBLE("orange_catholic_bible");
private final String yamlKey;
Saying(String yamlKey) {
this.yamlKey = yamlKey;
}
}
}

View File

@ -1,33 +0,0 @@
package com.github.javafaker;
public class Educator {
private final Faker faker;
protected Educator(Faker faker) {
this.faker = faker;
}
// TODO - move these all out to en.yml by default.
public String university() {
return faker.fakeValuesService().resolve("educator.name", this, faker)
+ " "
+ faker.fakeValuesService().resolve("educator.tertiary.type", this, faker);
}
public String course() {
return faker.fakeValuesService().resolve("educator.tertiary.degree.type", this, faker)
+ " "
+ faker.fakeValuesService().resolve("educator.tertiary.degree.subject", this, faker);
}
public String secondarySchool() {
return faker.fakeValuesService().resolve("educator.name", this, faker)
+ " "
+ faker.fakeValuesService().resolve("educator.secondary", this, faker);
}
public String campus() {
return faker.fakeValuesService().resolve("educator.name", this, faker) + " Campus";
}
}

View File

@ -1,41 +0,0 @@
package com.github.javafaker;
public class ElderScrolls {
private final Faker faker;
protected ElderScrolls(Faker faker) {
this.faker = faker;
}
public String race() {
return faker.fakeValuesService().resolve("games.elder_scrolls.race", this, faker);
}
public String creature() {
return faker.fakeValuesService().resolve("games.elder_scrolls.creature", this, faker);
}
public String region() {
return faker.fakeValuesService().resolve("games.elder_scrolls.region", this, faker);
}
public String dragon() {
return faker.fakeValuesService().resolve("games.elder_scrolls.dragon", this, faker);
}
public String city() {
return faker.fakeValuesService().resolve("games.elder_scrolls.city", this, faker);
}
public String firstName() {
return faker.fakeValuesService().resolve("games.elder_scrolls.first_name", this, faker);
}
public String lastName() {
return faker.fakeValuesService().resolve("games.elder_scrolls.last_name", this, faker);
}
public String quote() {return faker.fakeValuesService().resolve("games.elder_scrolls.quote", this, faker);
}
}

View File

@ -1,18 +0,0 @@
package com.github.javafaker;
public class EnglandFootBall {
private final Faker faker;
protected EnglandFootBall(final Faker faker) {
this.faker = faker;
}
public String league() {
return faker.fakeValuesService().resolve("englandfootball.leagues",this,faker);
}
public String team() {
return faker.fakeValuesService().resolve("englandfootball.teams",this,faker);
}
}

View File

@ -1,29 +0,0 @@
package com.github.javafaker;
public class Esports {
private final Faker faker;
protected Esports(final Faker faker) {
this.faker = faker;
}
public String player() {
return faker.resolve("esport.players");
}
public String team() {
return faker.resolve("esport.teams");
}
public String event() {
return faker.resolve("esport.events");
}
public String league() {
return faker.resolve("esport.leagues");
}
public String game() {
return faker.resolve("esport.games");
}
}

View File

@ -1,717 +0,0 @@
package com.github.javafaker;
import com.github.javafaker.service.FakeValuesService;
import com.github.javafaker.service.RandomService;
import java.util.Locale;
import java.util.Random;
/**
* Provides utility methods for generating fake strings, such as names, phone
* numbers, addresses. generate random strings with given patterns
*
* @author ren
*/
public class Faker {
private final RandomService randomService;
private final FakeValuesService fakeValuesService;
private final Ancient ancient;
private final App app;
private final Artist artist;
private final Avatar avatar;
private final Aviation aviation;
private final Lorem lorem;
private final Music music;
private final Name name;
private final Number number;
private final Internet internet;
private final PhoneNumber phoneNumber;
private final Pokemon pokemon;
private final Address address;
private final Business business;
private final Book book;
private final ChuckNorris chuckNorris;
private final Color color;
private final Commerce commerce;
private final Country country;
private final Currency currency;
private final Company company;
private final Crypto crypto;
private final IdNumber idNumber;
private final Hacker hacker;
private final Options options;
private final Code code;
private final Coin coin;
private final Finance finance;
private final Food food;
private final GameOfThrones gameOfThrones;
private final Gender gender;
private final DateAndTime dateAndTime;
private final Demographic demographic;
private final Dog dog;
private final Educator educator;
private final ElderScrolls elderScrolls;
private final Shakespeare shakespeare;
private final SlackEmoji slackEmoji;
private final Space space;
private final Superhero superhero;
private final Bool bool;
private final Team team;
private final Beer beer;
private final University university;
private final Cat cat;
private final File file;
private final Stock stock;
private final LordOfTheRings lordOfTheRings;
private final Zelda zelda;
private final HarryPotter harryPotter;
private final RockBand rockBand;
private final Esports esports;
private final Friends friends;
private final Hipster hipster;
private final Job job;
private final TwinPeaks twinPeaks;
private final RickAndMorty rickAndMorty;
private final Yoda yoda;
private final Matz matz;
private final Witcher witcher;
private final DragonBall dragonBall;
private final FunnyName funnyName;
private final HitchhikersGuideToTheGalaxy hitchhikersGuideToTheGalaxy;
private final Hobbit hobbit;
private final HowIMetYourMother howIMetYourMother;
private final LeagueOfLegends leagueOfLegends;
private final Overwatch overwatch;
private final Robin robin;
private final StarTrek starTrek;
private final Weather weather;
private final Lebowski lebowski;
private final Medical medical;
private final Animal animal;
private final BackToTheFuture backToTheFuture;
private final PrincessBride princessBride;
private final Buffy buffy;
private final Relationships relationships;
private final Nation nation;
private final Dune dune;
private final AquaTeenHungerForce aquaTeenHungerForce;
private final ProgrammingLanguage programmingLanguage;
private final Kaamelott kaamelott;
private final Photography photography;
private final StarCraft starCraft;
private final BojackHorseman bojackHorseman;
private final Disease disease;
private final Basketball basketball;
private final Barcode barcode;
private final Sip sip;
private final EnglandFootBall englandfootball;
private final Mountain mountain;
public Faker() {
this(Locale.ENGLISH);
}
public Faker(Locale locale) {
this(locale, (Random)null);
}
public Faker(Random random) {
this(Locale.ENGLISH, random);
}
public Faker(Locale locale, Random random) {
this(locale, new RandomService(random));
}
public Faker(Locale locale, RandomService randomService) {
this(new FakeValuesService(locale, randomService), randomService);
}
public Faker(FakeValuesService fakeValuesService, RandomService random) {
this.randomService = random;
this.fakeValuesService = fakeValuesService;
this.ancient = new Ancient(this);
this.app = new App(this);
this.artist = new Artist(this);
this.avatar = new Avatar(this);
this.aviation = new Aviation(this);
this.lorem = new Lorem(this);
this.music = new Music(this);
this.name = new Name(this);
this.number = new Number(this);
this.internet = new Internet(this);
this.phoneNumber = new PhoneNumber(this);
this.pokemon = new Pokemon(this);
this.address = new Address(this);
this.book = new Book(this);
this.business = new Business(this);
this.chuckNorris = new ChuckNorris(this);
this.color = new Color(this);
this.idNumber = new IdNumber(this);
this.hacker = new Hacker(this);
this.company = new Company(this);
this.crypto = new Crypto(this);
this.elderScrolls = new ElderScrolls(this);
this.commerce = new Commerce(this);
this.currency = new Currency(this);
this.options = new Options(this);
this.code = new Code(this);
this.file = new File(this);
this.finance = new Finance(this);
this.food = new Food(this);
this.gameOfThrones = new GameOfThrones(this);
this.gender = new Gender(this);
this.dateAndTime = new DateAndTime(this);
this.demographic = new Demographic(this);
this.dog = new Dog(this);
this.educator = new Educator(this);
this.shakespeare = new Shakespeare(this);
this.slackEmoji = new SlackEmoji(this);
this.space = new Space(this);
this.coin = new Coin(this);
this.superhero = new Superhero(this);
this.team = new Team(this);
this.bool = new Bool(this);
this.beer = new Beer(this);
this.university = new University(this);
this.cat = new Cat(this);
this.stock = new Stock(this);
this.lordOfTheRings = new LordOfTheRings(this);
this.zelda = new Zelda(this);
this.harryPotter = new HarryPotter(this);
this.rockBand = new RockBand(this);
this.esports = new Esports(this);
this.friends = new Friends(this);
this.hipster = new Hipster(this);
this.job = new Job(this);
this.twinPeaks = new TwinPeaks(this);
this.rickAndMorty = new RickAndMorty(this);
this.yoda = new Yoda(this);
this.matz = new Matz(this);
this.witcher = new Witcher(this);
this.dragonBall = new DragonBall(this);
this.funnyName = new FunnyName(this);
this.hitchhikersGuideToTheGalaxy = new HitchhikersGuideToTheGalaxy(this);
this.hobbit = new Hobbit(this);
this.howIMetYourMother = new HowIMetYourMother(this);
this.leagueOfLegends = new LeagueOfLegends(this);
this.overwatch = new Overwatch(this);
this.robin = new Robin(this);
this.starTrek = new StarTrek(this);
this.weather = new Weather(this);
this.lebowski = new Lebowski(this);
this.medical = new Medical(this);
this.country = new Country(this);
this.animal = new Animal(this);
this.backToTheFuture = new BackToTheFuture(this);
this.princessBride = new PrincessBride(this);
this.buffy = new Buffy(this);
this.relationships = new Relationships(this);
this.nation = new Nation(this);
this.dune = new Dune(this);
this.aquaTeenHungerForce = new AquaTeenHungerForce(this);
this.programmingLanguage = new ProgrammingLanguage(this);
this.kaamelott = new Kaamelott(this);
this.photography = new Photography(this);
this.starCraft = new StarCraft(this);
this.bojackHorseman = new BojackHorseman(this);
this.disease = new Disease(this);
this.basketball = new Basketball(this);
this.barcode = new Barcode(this);
this.sip = new Sip(this);
this.englandfootball = new EnglandFootBall(this);
this.mountain = new Mountain(this);
}
/**
* Constructs Faker instance with default argument.
*
* @return {@link Faker#Faker()}
*/
public static Faker instance() {
return new Faker();
}
/**
* Constructs Faker instance with provided {@link Locale}.
*
* @param locale - {@link Locale}
* @return {@link Faker#Faker(Locale)}
*/
public static Faker instance(Locale locale) {
return new Faker(locale);
}
/**
* Constructs Faker instance with provided {@link Random}.
*
* @param random - {@link Random}
* @return {@link Faker#Faker(Random)}
*/
public static Faker instance(Random random) {
return new Faker(random);
}
/**
* Constructs Faker instance with provided {@link Locale} and {@link Random}.
*
* @param locale - {@link Locale}
* @param random - {@link Random}
* @return {@link Faker#Faker(Locale, Random)}
*/
public static Faker instance(Locale locale, Random random) {
return new Faker(locale, random);
}
/**
* Returns a string with the '#' characters in the parameter replaced with random digits between 0-9 inclusive.
* <p>
* For example, the string "ABC##EFG" could be replaced with a string like "ABC99EFG".
*
* @param numberString
* @return
*/
public String numerify(String numberString) {
return fakeValuesService.numerify(numberString);
}
/**
* Returns a string with the '?' characters in the parameter replaced with random alphabetic
* characters.
* <p>
* For example, the string "12??34" could be replaced with a string like "12AB34".
*
* @param letterString
* @return
*/
public String letterify(String letterString) {
return fakeValuesService.letterify(letterString);
}
/**
* Returns a string with the '?' characters in the parameter replaced with random alphabetic
* characters.
* <p>
* For example, the string "12??34" could be replaced with a string like "12AB34".
*
* @param letterString
* @param isUpper
* @return
*/
public String letterify(String letterString, boolean isUpper) {
return fakeValuesService.letterify(letterString, isUpper);
}
/**
* Applies both a {@link #numerify(String)} and a {@link #letterify(String)}
* over the incoming string.
*
* @param string
* @return
*/
public String bothify(String string) {
return fakeValuesService.bothify(string);
}
/**
* Applies both a {@link #numerify(String)} and a {@link #letterify(String)}
* over the incoming string.
*
* @param string
* @param isUpper
* @return
*/
public String bothify(String string, boolean isUpper) {
return fakeValuesService.bothify(string, isUpper);
}
/**
* Generates a String that matches the given regular expression.
*/
public String regexify(String regex) {
return fakeValuesService.regexify(regex);
}
public RandomService random() {
return this.randomService;
}
public Currency currency() {
return currency;
}
FakeValuesService fakeValuesService() {
return this.fakeValuesService;
}
public Ancient ancient() {
return ancient;
}
public App app() {
return app;
}
public Artist artist() {
return artist;
}
public Avatar avatar() {
return avatar;
}
public Aviation aviation() {
return aviation;
}
public Music music() {
return music;
}
public Name name() {
return name;
}
public Number number() {
return number;
}
public Internet internet() {
return internet;
}
public PhoneNumber phoneNumber() {
return phoneNumber;
}
public Pokemon pokemon() {
return pokemon;
}
public Lorem lorem() {
return lorem;
}
public Address address() {
return address;
}
public Book book() {
return book;
}
public Buffy buffy() {
return buffy;
}
public Business business() {
return business;
}
public ChuckNorris chuckNorris() {
return chuckNorris;
}
public Color color() {
return color;
}
public Commerce commerce() {
return commerce;
}
public Company company() {
return company;
}
public Crypto crypto() {
return crypto;
}
public Hacker hacker() {
return hacker;
}
public IdNumber idNumber() {
return idNumber;
}
public Options options() {
return options;
}
public Code code() {
return code;
}
public Coin coin() {
return coin;
}
public File file() {
return file;
}
public Finance finance() {
return finance;
}
public Food food() {
return food;
}
public ElderScrolls elderScrolls() {
return elderScrolls;
}
public GameOfThrones gameOfThrones() {
return gameOfThrones;
}
public Gender gender() {
return gender;
}
public DateAndTime date() {
return dateAndTime;
}
public Demographic demographic() {
return demographic;
}
public Dog dog() {
return dog;
}
public Educator educator() {
return educator;
}
public SlackEmoji slackEmoji() {
return slackEmoji;
}
public Shakespeare shakespeare() {
return shakespeare;
}
public Space space() {
return space;
}
public Superhero superhero() {
return superhero;
}
public Bool bool() {
return bool;
}
public Team team() {
return team;
}
public Beer beer() { return beer; }
public University university() {
return university;
}
public Cat cat() {
return cat;
}
public Stock stock() {
return stock;
}
public LordOfTheRings lordOfTheRings() {
return lordOfTheRings;
}
public Zelda zelda() {
return zelda;
}
public HarryPotter harryPotter() {
return harryPotter;
}
public RockBand rockBand() {
return rockBand;
}
public Esports esports() {
return esports;
}
public Friends friends() {
return friends;
}
public Hipster hipster() {
return hipster;
}
public Job job() {
return job;
}
public TwinPeaks twinPeaks() {
return twinPeaks;
}
public RickAndMorty rickAndMorty() {
return rickAndMorty;
}
public Yoda yoda() {
return yoda;
}
public Matz matz() {
return matz;
}
public Witcher witcher() {
return witcher;
}
public DragonBall dragonBall() {
return dragonBall;
}
public FunnyName funnyName() {
return funnyName;
}
public HitchhikersGuideToTheGalaxy hitchhikersGuideToTheGalaxy() {
return hitchhikersGuideToTheGalaxy;
}
public Hobbit hobbit() {
return hobbit;
}
public HowIMetYourMother howIMetYourMother() {
return howIMetYourMother;
}
public LeagueOfLegends leagueOfLegends() {
return leagueOfLegends;
}
public Overwatch overwatch() {
return overwatch;
}
public Robin robin() {
return robin;
}
public StarTrek starTrek() {
return starTrek;
}
public Weather weather() {
return weather;
}
public Lebowski lebowski() {
return lebowski;
}
public Medical medical() {
return medical;
}
public Country country() {
return country;
}
public Animal animal() {
return animal;
}
public BackToTheFuture backToTheFuture() {
return backToTheFuture;
}
public PrincessBride princessBride() {
return princessBride;
}
public Relationships relationships() {
return relationships;
}
public Nation nation() {
return nation;
}
public Dune dune() {
return dune;
}
public AquaTeenHungerForce aquaTeenHungerForce() {
return aquaTeenHungerForce;
}
public ProgrammingLanguage programmingLanguage() {
return programmingLanguage;
}
public Kaamelott kaamelott() {
return kaamelott;
}
public Photography photography() {
return photography;
}
public StarCraft starCraft() {
return starCraft;
}
public BojackHorseman bojackHorseman() { return bojackHorseman; }
public Disease disease() {return disease; }
public Basketball basketball() { return basketball; }
public Barcode barcode() { return barcode; }
public Sip sip() { return sip; }
public EnglandFootBall englandfootball() { return englandfootball; }
public Mountain mountain() { return mountain; }
public String resolve(String key) {
return this.fakeValuesService.resolve(key, this, this);
}
/**
* Allows the evaluation of native YML expressions to allow you to build your own.
* <p>
* The following are valid expressions:
* <ul>
* <li>#{regexify '(a|b){2,3}'}</li>
* <li>#{regexify '\\.\\*\\?\\+'}</li>
* <li>#{bothify '????','false'}</li>
* <li>#{Name.first_name} #{Name.first_name} #{Name.last_name}</li>
* <li>#{number.number_between '1','10'}</li>
* </ul>
*
* @param expression (see examples above)
* @return the evaluated string expression
* @throws RuntimeException if unable to evaluate the expression
*/
public String expression(String expression) {
return this.fakeValuesService.expression(expression, this);
}
}

View File

@ -1,29 +0,0 @@
package com.github.javafaker;
public class File {
private final Faker faker;
protected File(Faker faker) {
this.faker = faker;
}
public String extension() {
return faker.resolve("file.extension");
}
public String mimeType() {
return faker.resolve("file.mime_type");
}
public String fileName() {
return fileName(null, null, null, null);
}
public String fileName(String dirOrNull, String nameOrNull, String extensionOrNull, String separatorOrNull) {
final String sep = separatorOrNull == null ? System.getProperty("file.separator") : separatorOrNull;
final String dir = dirOrNull == null ? faker.internet().slug() : dirOrNull;
final String name = nameOrNull == null ? faker.lorem().word().toLowerCase() : nameOrNull;
final String ext = extensionOrNull == null ? extension() : extensionOrNull;
return dir + sep + name + "." + ext;
}
}

View File

@ -1,173 +0,0 @@
package com.github.javafaker;
import org.apache.commons.lang3.StringUtils;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Finance {
private final Faker faker;
protected Finance(Faker faker) {
this.faker = faker;
}
private static final Map<String, String> countryCodeToBasicBankAccountNumberPattern =
createCountryCodeToBasicBankAccountNumberPatternMap();
public String creditCard(CreditCardType creditCardType) {
final String key = String.format("finance.credit_card.%s", creditCardType.toString().toLowerCase());
String value = faker.fakeValuesService().resolve(key, this, faker);
final String template = faker.numerify(value);
String[] split = template.replaceAll("[^0-9]", "").split("");
List<Integer> reversedAsInt = new ArrayList<Integer>();
for (int i = 0; i < split.length; i++) {
final String current = split[split.length - 1 - i];
if (!current.isEmpty()) {
reversedAsInt.add(Integer.valueOf(current));
}
}
int luhnSum = 0;
int multiplier = 1;
for (Integer digit : reversedAsInt) {
multiplier = (multiplier == 2 ? 1 : 2);
luhnSum += sum(String.valueOf(digit * multiplier).split(""));
}
int luhnDigit = (10 - (luhnSum % 10)) % 10;
return template.replace('\\', ' ').replace('/', ' ').trim().replace('L', String.valueOf(luhnDigit).charAt(0));
}
public String creditCard() {
CreditCardType type = randomCreditCardType();
return creditCard(type);
}
/**
* Generates a random Business Identifier Code
*/
public String bic() {
return faker.regexify("([A-Z]){4}([A-Z]){2}([0-9A-Z]){2}([0-9A-Z]{3})?");
}
public String iban() {
List<String> countryCodes = new ArrayList<String>(countryCodeToBasicBankAccountNumberPattern.keySet());
String randomCountryCode = countryCodes.get(faker.random().nextInt(countryCodes.size()));
return iban(randomCountryCode);
}
public String iban(String countryCode) {
String basicBankAccountNumber = faker.regexify(countryCodeToBasicBankAccountNumberPattern.get(countryCode));
String checkSum = calculateIbanChecksum(countryCode, basicBankAccountNumber);
return countryCode + checkSum + basicBankAccountNumber;
}
private CreditCardType randomCreditCardType() {
return CreditCardType.values()[this.faker.random().nextInt(CreditCardType.values().length)];
}
private static int sum(String[] string) {
int sum = 0;
for (String s : string) {
if (!s.isEmpty()) {
sum += Integer.valueOf(s);
}
}
return sum;
}
private static String calculateIbanChecksum(String countryCode, String basicBankAccountNumber) {
String basis = basicBankAccountNumber + countryCode + "00";
StringBuilder sb = new StringBuilder();
char[] characters = basis.toLowerCase().toCharArray();
for (char c : characters) {
if (Character.isLetter(c)) {
sb.append(String.valueOf((c - 'a') + 10));
} else {
sb.append(c);
}
}
int mod97 = new BigInteger(sb.toString()).mod(BigInteger.valueOf(97L)).intValue();
return StringUtils.leftPad(String.valueOf(98 - mod97), 2, '0');
}
private static Map<String, String> createCountryCodeToBasicBankAccountNumberPatternMap() {
// source: https://www.swift.com/standards/data-standards/iban
Map<String, String> ibanFormats = new HashMap<String, String>();
ibanFormats.put("AL", "\\d{8}[0-9A-Za-z]{16}");
ibanFormats.put("AD", "\\d{4}\\d{4}[0-9A-Za-z]{12}");
ibanFormats.put("AT", "\\d{5}\\d{11}");
ibanFormats.put("AZ", "[A-Z]{4}[0-9A-Za-z]{20}");
ibanFormats.put("BH", "[A-Z]{4}[0-9A-Za-z]{14}");
ibanFormats.put("BE", "\\d{3}\\d{7}\\d{2}");
ibanFormats.put("BA", "\\d{3}\\d{3}\\d{8}\\d{2}");
ibanFormats.put("BR", "\\d{8}\\d{5}\\d{10}[A-Z]{1}[0-9A-Za-z]{1}");
ibanFormats.put("BG", "[A-Z]{4}\\d{4}\\d{2}[0-9A-Za-z]{8}");
ibanFormats.put("CR", "\\d{3}\\d{14}");
ibanFormats.put("HR", "\\d{7}\\d{10}");
ibanFormats.put("CY", "\\d{3}\\d{5}[0-9A-Za-z]{16}");
ibanFormats.put("DK", "\\d{4}\\d{9}\\d{1}");
ibanFormats.put("DO", "[0-9A-Za-z]{4}\\d{20}");
ibanFormats.put("EE", "\\d{2}\\d{2}\\d{11}\\d{1}");
ibanFormats.put("FI", "\\d{6}\\d{7}\\d{1}");
ibanFormats.put("FR", "\\d{5}\\d{5}[0-9A-Za-z]{11}\\d{2}");
ibanFormats.put("GE", "[A-Z]{2}\\d{16}");
ibanFormats.put("DE", "\\d{8}\\d{10}");
ibanFormats.put("GI", "[A-Z]{4}[0-9A-Za-z]{15}");
ibanFormats.put("GR", "\\d{3}\\d{4}[0-9A-Za-z]{16}");
ibanFormats.put("GT", "[0-9A-Za-z]{4}[0-9A-Za-z]{20}");
ibanFormats.put("HU", "\\d{3}\\d{4}\\d{1}\\d{15}\\d{1}");
ibanFormats.put("IS", "\\d{4}\\d{2}\\d{6}\\d{10}");
ibanFormats.put("IE", "[A-Z]{4}\\d{6}\\d{8}");
ibanFormats.put("IL", "\\d{3}\\d{3}\\d{13}");
ibanFormats.put("IT", "[A-Z]{1}\\d{5}\\d{5}[0-9A-Za-z]{12}");
ibanFormats.put("JO", "[A-Z]{4}\\d{4}[0-9A-Za-z]{18}");
ibanFormats.put("KZ", "\\d{3}[0-9A-Za-z]{13}");
ibanFormats.put("XK", "\\d{4}\\d{10}\\d{2}");
ibanFormats.put("KW", "[A-Z]{4}[0-9A-Za-z]{22}");
ibanFormats.put("LV", "[A-Z]{4}[0-9A-Za-z]{13}");
ibanFormats.put("LB", "\\d{4}[0-9A-Za-z]{20}");
ibanFormats.put("LI", "\\d{5}[0-9A-Za-z]{12}");
ibanFormats.put("LT", "\\d{5}\\d{11}");
ibanFormats.put("LU", "\\d{3}[0-9A-Za-z]{13}");
ibanFormats.put("MK", "\\d{3}[0-9A-Za-z]{10}\\d{2}");
ibanFormats.put("MT", "[A-Z]{4}\\d{5}[0-9A-Za-z]{18}");
ibanFormats.put("MR", "\\d{5}\\d{5}\\d{11}\\d{2}");
ibanFormats.put("MU", "[A-Z]{4}\\d{2}\\d{2}\\d{12}\\d{3}[A-Z]{3}");
ibanFormats.put("MD", "[0-9A-Za-z]{2}[0-9A-Za-z]{18}");
ibanFormats.put("MC", "\\d{5}\\d{5}[0-9A-Za-z]{11}\\d{2}");
ibanFormats.put("ME", "\\d{3}\\d{13}\\d{2}");
ibanFormats.put("NL", "[A-Z]{4}\\d{10}");
ibanFormats.put("NO", "\\d{4}\\d{6}\\d{1}");
ibanFormats.put("PK", "[A-Z]{4}[0-9A-Za-z]{16}");
ibanFormats.put("PS", "[A-Z]{4}[0-9A-Za-z]{21}");
ibanFormats.put("PL", "\\d{8}\\d{16}");
ibanFormats.put("PT", "\\d{4}\\d{4}\\d{11}\\d{2}");
ibanFormats.put("QA", "[A-Z]{4}[0-9A-Za-z]{21}");
ibanFormats.put("RO", "[A-Z]{4}[0-9A-Za-z]{16}");
ibanFormats.put("LC", "[A-Z]{4}[0-9A-Za-z]{24}");
ibanFormats.put("SM", "[A-Z]{1}\\d{5}\\d{5}[0-9A-Za-z]{12}");
ibanFormats.put("ST", "\\d{8}\\d{11}\\d{2}");
ibanFormats.put("SA", "\\d{2}[0-9A-Za-z]{18}");
ibanFormats.put("RS", "\\d{3}\\d{13}\\d{2}");
ibanFormats.put("SK", "\\d{4}\\d{6}\\d{10}");
ibanFormats.put("SI", "\\d{5}\\d{8}\\d{2}");
ibanFormats.put("ES", "\\d{4}\\d{4}\\d{1}\\d{1}\\d{10}");
ibanFormats.put("SE", "\\d{3}\\d{16}\\d{1}");
ibanFormats.put("CH", "\\d{5}[0-9A-Za-z]{12}");
ibanFormats.put("TL", "\\d{3}\\d{14}\\d{2}");
ibanFormats.put("TN", "\\d{2}\\d{3}\\d{13}\\d{2}");
ibanFormats.put("TR", "\\d{5}\\d{1}[0-9A-Za-z]{16}");
ibanFormats.put("UA", "\\d{6}[0-9A-Za-z]{19}");
ibanFormats.put("AE", "\\d{3}\\d{16}");
ibanFormats.put("GB", "[A-Z]{4}\\d{6}\\d{8}");
ibanFormats.put("VG", "[A-Z]{4}\\d{16}");
return ibanFormats;
}
}

View File

@ -1,39 +0,0 @@
package com.github.javafaker;
public class Food {
private final Faker faker;
protected Food(Faker faker) {
this.faker = faker;
}
public String ingredient() {
return faker.fakeValuesService().resolve("food.ingredients", this, faker);
}
public String spice() {
return faker.fakeValuesService().resolve("food.spices", this, faker);
}
public String dish() {
return faker.fakeValuesService().resolve("food.dish", this, faker);
}
public String fruit() {
return faker.fakeValuesService().resolve("food.fruits", this, faker);
}
public String vegetable() {
return faker.fakeValuesService().resolve("food.vegetables", this, faker);
}
public String sushi() {
return faker.fakeValuesService().resolve("food.sushi", this, faker);
}
public String measurement() {
return faker.fakeValuesService().resolve("food.measurement_sizes", this, faker) +
" " + faker.fakeValuesService().resolve("food.measurements", this, faker);
}
}

View File

@ -1,21 +0,0 @@
package com.github.javafaker;
public class Friends {
private final Faker faker;
protected Friends(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.resolve("friends.characters");
}
public String location() {
return faker.resolve("friends.locations");
}
public String quote() {
return faker.resolve("friends.quotes");
}
}

View File

@ -1,13 +0,0 @@
package com.github.javafaker;
public class FunnyName {
private final Faker faker;
protected FunnyName(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("funny_name.name", this, faker);
}
}

View File

@ -1,30 +0,0 @@
package com.github.javafaker;
public class GameOfThrones {
private final Faker faker;
protected GameOfThrones(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.resolve("game_of_thrones.characters");
}
public String house() {
return faker.resolve("game_of_thrones.houses");
}
public String city() {
return faker.resolve("game_of_thrones.cities");
}
public String dragon() {
return faker.resolve("game_of_thrones.dragons");
}
public String quote() {
return faker.resolve("game_of_thrones.quotes");
}
}

View File

@ -1,41 +0,0 @@
package com.github.javafaker;
/**
* This class is used to generate gender randomly.
*
*/
public class Gender {
private final Faker faker;
protected Gender(Faker faker) {
this.faker = faker;
}
/**
* This method returns a gender type
*
* @return a string of gender type
*/
public String types() {
return faker.fakeValuesService().fetchString("gender.types");
}
/**
* This method returns a binary gender type
*
* @return a string of binary gender type
*/
public String binaryTypes() {
return faker.fakeValuesService().fetchString("gender.binary_types");
}
/**
* This method returns a short binary gender type
*
* @return a string of short binary gender type
*/
public String shortBinaryTypes() {
return faker.fakeValuesService().fetchString("gender.short_binary_types");
}
}

View File

@ -1,29 +0,0 @@
package com.github.javafaker;
public class Hacker {
private final Faker faker;
protected Hacker(Faker faker) {
this.faker = faker;
}
public String abbreviation() {
return faker.fakeValuesService().resolve("hacker.abbreviation", this, faker);
}
public String adjective() {
return faker.fakeValuesService().resolve("hacker.adjective", this, faker);
}
public String noun() {
return faker.fakeValuesService().resolve("hacker.noun", this, faker);
}
public String verb() {
return faker.fakeValuesService().resolve("hacker.verb", this, faker);
}
public String ingverb() {
return faker.fakeValuesService().resolve("hacker.ingverb", this, faker);
}
}

View File

@ -1,33 +0,0 @@
package com.github.javafaker;
public class HarryPotter {
private final Faker faker;
protected HarryPotter(final Faker faker) {
this.faker = faker;
}
public String character() {
return faker.resolve("harry_potter.characters");
}
public String location() {
return faker.resolve("harry_potter.locations");
}
public String quote() {
return faker.resolve("harry_potter.quotes");
}
public String book() {
return faker.resolve("harry_potter.books");
}
public String house() {
return faker.resolve("harry_potter.houses");
}
public String spell() {
return faker.resolve("harry_potter.spells");
}
}

View File

@ -1,13 +0,0 @@
package com.github.javafaker;
public class Hipster {
private final Faker faker;
protected Hipster(final Faker faker) {
this.faker = faker;
}
public String word() {
return faker.resolve("hipster.words");
}
}

View File

@ -1,37 +0,0 @@
package com.github.javafaker;
public class HitchhikersGuideToTheGalaxy {
private final Faker faker;
protected HitchhikersGuideToTheGalaxy(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.characters", this, faker);
}
public String location() {
return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.locations", this, faker);
}
public String marvinQuote() {
return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.marvin_quote", this, faker);
}
public String planet() {
return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.planets", this, faker);
}
public String quote() {
return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.quotes", this, faker);
}
public String specie() {
return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.species", this, faker);
}
public String starship() {
return faker.fakeValuesService().resolve("hitchhikers_guide_to_the_galaxy.starships", this, faker);
}
}

View File

@ -1,25 +0,0 @@
package com.github.javafaker;
public class Hobbit {
private final Faker faker;
protected Hobbit(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.fakeValuesService().resolve("hobbit.character", this, faker);
}
public String thorinsCompany() {
return faker.fakeValuesService().resolve("hobbit.thorins_company", this, faker);
}
public String quote() {
return faker.fakeValuesService().resolve("hobbit.quote", this, faker);
}
public String location() {
return faker.fakeValuesService().resolve("hobbit.location", this, faker);
}
}

View File

@ -1,25 +0,0 @@
package com.github.javafaker;
public class HowIMetYourMother {
private final Faker faker;
protected HowIMetYourMother(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.fakeValuesService().resolve("how_i_met_your_mother.character", this, faker);
}
public String catchPhrase() {
return faker.fakeValuesService().resolve("how_i_met_your_mother.catch_phrase", this, faker);
}
public String highFive() {
return faker.fakeValuesService().resolve("how_i_met_your_mother.high_five", this, faker);
}
public String quote() {
return faker.fakeValuesService().resolve("how_i_met_your_mother.quote", this, faker);
}
}

View File

@ -1,41 +0,0 @@
package com.github.javafaker;
import com.github.javafaker.idnumbers.EnIdNumber;
import com.github.javafaker.idnumbers.SvSEIdNumber;
public class IdNumber {
private final Faker faker;
protected IdNumber(Faker faker) {
this.faker = faker;
}
public String valid() {
return faker.fakeValuesService().resolve("id_number.valid", this, faker);
}
public String invalid() {
return faker.numerify(faker.fakeValuesService().resolve("id_number.invalid", this, faker));
}
public String ssnValid() {
EnIdNumber enIdNumber = new EnIdNumber();
return enIdNumber.getValidSsn(faker);
}
/**
* Specified as #{IDNumber.valid_sv_se_ssn} in sv-SE.yml
*/
public String validSvSeSsn() {
SvSEIdNumber svSEIdNumber = new SvSEIdNumber();
return svSEIdNumber.getValidSsn(faker);
}
/**
* Specified as #{IDNumber.invalid_sv_se_ssn} in sv-SE.yml
*/
public String invalidSvSeSsn() {
SvSEIdNumber svSEIdNumber = new SvSEIdNumber();
return svSEIdNumber.getInvalidSsn(faker);
}
}

View File

@ -1,351 +0,0 @@
package com.github.javafaker;
import com.github.javafaker.service.FakerIDN;
import com.github.javafaker.service.RandomService;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import static org.apache.commons.lang3.StringUtils.join;
import static org.apache.commons.lang3.StringUtils.stripAccents;
public class Internet {
private final Faker faker;
protected Internet(Faker faker) {
this.faker = faker;
}
public String emailAddress() {
return emailAddress(faker.name().username());
}
public String emailAddress(String localPart) {
return emailAddress(localPart, FakerIDN.toASCII(faker.fakeValuesService().resolve("internet.free_email", this, faker)));
}
public String safeEmailAddress() {
return safeEmailAddress(faker.name().username());
}
public String safeEmailAddress(String localPart) {
return emailAddress(localPart, FakerIDN.toASCII(faker.fakeValuesService().resolve("internet.safe_email", this, faker)));
}
private String emailAddress(String localPart, String domain) {
return join(stripAccents(localPart), "@", domain);
}
public String domainName() {
return domainWord() + "." + domainSuffix();
}
public String domainWord() {
return FakerIDN.toASCII(faker.name().lastName().toLowerCase().replaceAll("'", ""));
}
public String domainSuffix() {
return faker.fakeValuesService().resolve("internet.domain_suffix", this, faker);
}
public String url() {
return join(
"www",
".",
FakerIDN.toASCII(
faker.name().firstName().toLowerCase().replaceAll("'", "") +
"-" +
domainWord()
),
".",
domainSuffix()
);
}
/**
* Generates a random avatar url based on a collection of profile pictures of real people. All this avatar have been
* authorized by its awesome users to be used on live websites (not just mockups). For more information, please
* visit: http://uifaces.com/authorized
*
* @return an url to a random avatar image.
* @see <a href="http://uifaces.com/authorized">Authorized UI Faces</a>
*/
public String avatar() {
return "https://s3.amazonaws.com/uifaces/faces/twitter/" + faker.fakeValuesService().resolve("internet.avatar", this, faker);
}
/**
* Generates a random image url based on the lorempixel service. All the images provided by this service are released
* under the creative commons license (CC BY-SA). For more information, please visit: http://lorempixel.com/
*
* @return an url to a random image.
* @see <a href="http://lorempixel.com/">lorempixel - Placeholder Images for every case</a>
*/
public String image() {
String[] dimension = StringUtils.split(faker.fakeValuesService().resolve("internet.image_dimension", this, faker), 'x');
if (dimension.length == 0) return "";
return image(
Integer.valueOf(StringUtils.trim(dimension[0])), Integer.valueOf(StringUtils.trim(dimension[1])),
faker.bool().bool(), null);
}
/**
* Same as image() but allows client code to choose a few image characteristics
*
* @param width the image width
* @param height the image height
* @param gray true for gray image and false for color image
* @param text optional custom text on the selected picture
* @return an url to a random image with the given characteristics.
*/
public String image(Integer width, Integer height, Boolean gray, String text) {
return String.format("http://lorempixel.com/%s%s/%s/%s/%s",
gray ? "g/" : StringUtils.EMPTY, width, height, faker.fakeValuesService().resolve("internet.image_category", this, faker),
StringUtils.isEmpty(text) ? StringUtils.EMPTY : text);
}
public String password() {
return password(8, 16);
}
public String password(boolean includeDigit) {
return password(8, 16, false, false, includeDigit);
}
public String password(int minimumLength, int maximumLength) {
return password(minimumLength, maximumLength, false);
}
public String password(int minimumLength, int maximumLength, boolean includeUppercase) {
return password(minimumLength, maximumLength, includeUppercase, false);
}
public String password(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeSpecial) {
return password(minimumLength, maximumLength, includeUppercase, includeSpecial, true);
}
public String password(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeSpecial, boolean includeDigit) {
if (includeSpecial) {
char[] password = faker.lorem().characters(minimumLength, maximumLength, includeUppercase, includeDigit).toCharArray();
char[] special = new char[]{'!', '@', '#', '$', '%', '^', '&', '*'};
for (int i = 0; i < faker.random().nextInt(minimumLength); i++) {
password[faker.random().nextInt(password.length)] = special[faker.random().nextInt(special.length)];
}
return new String(password);
} else {
return faker.lorem().characters(minimumLength, maximumLength, includeUppercase, includeDigit);
}
}
/**
* <p>Returns a MAC address in the following format: 6-bytes in MM:MM:MM:SS:SS:SS format.</p>
* @return a correctly formatted MAC address
* @param prefix a prefix to put on the front of the address
*/
public String macAddress(String prefix) {
final String tmp = (prefix == null) ? "" : prefix;
final int prefixLength = tmp.trim().length() == 0
? 0
: tmp.split(":").length;
final StringBuilder out = new StringBuilder(tmp);
for (int i=0;i < 6 - prefixLength;i++) {
if (out.length() > 0) {
out.append(':');
}
out.append(Integer.toHexString(faker.random().nextInt(16)));
out.append(Integer.toHexString(faker.random().nextInt(16)));
}
return out.toString();
}
/**
* @see Internet#macAddress(String)
*/
public String macAddress() {
return macAddress("");
}
/**
* returns an IPv4 address in dot separated octets.
* @return a correctly formatted IPv4 address.
*/
public String ipV4Address() {
return String.format("%d.%d.%d.%d",
faker.random().nextInt(254) + 2,
faker.random().nextInt(254) + 2,
faker.random().nextInt(254) + 2,
faker.random().nextInt(254) + 2);
}
/**
* @return a valid private IPV4 address in dot notation
*/
public String privateIpV4Address() {
final Integer[] PRIVATE_FIRST_OCTET = {10,127,169,192,172};
final Integer[] PRIVATE_SECOND_OCTET_172 = {16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
final RandomService r = faker.random();
int first = random(PRIVATE_FIRST_OCTET),
second = r.nextInt(256),
third = r.nextInt(256),
fourth = r.nextInt(256);
switch (first) {
case 172:
second = random(PRIVATE_SECOND_OCTET_172);
break;
case 192:
second = 168;
break;
case 169:
second = 254;
break;
}
return String.format("%d.%d.%d.%d", first, second, third, fourth);
}
/**
* @return a valid public IPV4 address in dot notation
*/
public String publicIpV4Address() {
final RandomService r = faker.random();
final int[] PRIVATE_FIRST_OCTET = {10,127,169,192,172};
int first = r.nextInt(256),
second = r.nextInt(256),
third = r.nextInt(256),
fourth = r.nextInt(256);
while (Arrays.binarySearch(PRIVATE_FIRST_OCTET, first) > 0) {
first = r.nextInt(256);
}
return String.format("%d.%d.%d.%d", first, second, third, fourth);
}
/**
* @return a valid IPV4 CIDR
*/
public String ipV4Cidr() {
return new StringBuilder(ipV4Address())
.append('/')
.append(faker.random().nextInt(31) + 1)
.toString();
}
/**
* <p>Returns an IPv6 address in hh:hh:hh:hh:hh:hh:hh:hh format.</p>
* @return a correctly formatted IPv6 address.
*/
public String ipV6Address() {
final StringBuilder tmp = new StringBuilder();
for (int i=0;i < 8;i++) {
if (i > 0) {
tmp.append(":");
}
tmp.append(Integer.toHexString(faker.random().nextInt(16)));
tmp.append(Integer.toHexString(faker.random().nextInt(16)));
tmp.append(Integer.toHexString(faker.random().nextInt(16)));
tmp.append(Integer.toHexString(faker.random().nextInt(16)));
}
return tmp.toString();
}
/**
* @return a valid IPV6 CIDR
*/
public String ipV6Cidr() {
return new StringBuilder(ipV6Address())
.append('/')
.append(faker.random().nextInt(127) + 1)
.toString();
}
/**
* @return a slug using '_' as the word separator and two {@link Lorem} words as the values
*/
public String slug() {
return slug(faker.lorem().words(2), "_");
}
/**
* @param wordsOrNull if null, then 2 {@link Lorem} words
* @param glueOrNull if null, "_"
* @return a slug string combining wordsOrNull with glueOrNull (ex. x_y)
*/
public String slug(List<String> wordsOrNull, String glueOrNull) {
final String glue = glueOrNull == null
? "_"
: glueOrNull;
final List<String> words = wordsOrNull == null
? faker.lorem().words(2)
: wordsOrNull;
final StringBuilder slug = new StringBuilder();
for (int i = 0; i < words.size(); i++) {
if (i > 0) {
slug.append(glue);
}
slug.append(words.get(i));
}
return slug.toString();
}
/**
* Returns a UUID (type 4) as String.
* @return A UUID as String.
*/
public String uuid() {
return UUID.randomUUID().toString();
}
private <T> T random(T[] src) {
return src[faker.random().nextInt(src.length)];
}
public String userAgent(UserAgent userAgent) {
UserAgent agent = userAgent;
if(agent == null) {
agent = UserAgent.any();
}
String userAgentKey = "internet.user_agent." + agent.toString();
return faker.fakeValuesService().resolve(userAgentKey, this, faker);
}
public String userAgentAny() {
return userAgent(null);
}
public enum UserAgent {
AOL("aol"),
CHROME("chrome"),
FIREFOX("firefox"),
INTERNET_EXPLORER("internet_explorer"),
NETSCAPE("netscape"),
OPERA("opera"),
SAFARI("safari");
//Browser's name in corresponding yaml (internet.yml) file.
private String browserName;
UserAgent(String browserName) {
this.browserName = browserName;
}
private static UserAgent any() {
UserAgent[] agents = UserAgent.values();
int randomIndex = (int)(Math.random() * agents.length);
return agents[randomIndex];
}
@Override
public String toString() {
return browserName;
}
}
}

View File

@ -1,30 +0,0 @@
package com.github.javafaker;
public class Job {
private final Faker faker;
public Job(final Faker faker) {
this.faker = faker;
}
public String field() {
return faker.fakeValuesService().resolve("job.field", this, faker);
}
public String seniority() {
return faker.fakeValuesService().resolve("job.seniority", this, faker);
}
public String position() {
return faker.fakeValuesService().resolve("job.position", this, faker);
}
public String keySkills() {
return faker.fakeValuesService().resolve("job.key_skills", this, faker);
}
public String title() {
return faker.fakeValuesService().resolve("job.title", this, faker);
}
}

View File

@ -1,17 +0,0 @@
package com.github.javafaker;
public class Kaamelott {
private final Faker faker;
protected Kaamelott(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.fakeValuesService().resolve("kaamelott.characters", this, faker);
}
public String quote() {
return faker.fakeValuesService().resolve("kaamelott.quotes", this, faker);
}
}

View File

@ -1,33 +0,0 @@
package com.github.javafaker;
public class LeagueOfLegends {
private final Faker faker;
protected LeagueOfLegends(Faker faker) {
this.faker = faker;
}
public String champion() {
return faker.fakeValuesService().resolve("games.league_of_legends.champion", this, faker);
}
public String location() {
return faker.fakeValuesService().resolve("games.league_of_legends.location", this, faker);
}
public String quote() {
return faker.fakeValuesService().resolve("games.league_of_legends.quote", this, faker);
}
public String summonerSpell() {
return faker.fakeValuesService().resolve("games.league_of_legends.summoner_spell", this, faker);
}
public String masteries() {
return faker.fakeValuesService().resolve("games.league_of_legends.masteries", this, faker);
}
public String rank() {
return faker.fakeValuesService().resolve("games.league_of_legends.rank", this, faker);
}
}

View File

@ -1,21 +0,0 @@
package com.github.javafaker;
public class Lebowski {
private final Faker faker;
public Lebowski(final Faker faker) {
this.faker = faker;
}
public String actor() {
return faker.fakeValuesService().resolve("lebowski.actors", this, faker);
}
public String character() {
return faker.fakeValuesService().resolve("lebowski.characters", this, faker);
}
public String quote() {
return faker.fakeValuesService().resolve("lebowski.quotes", this, faker);
}
}

View File

@ -1,17 +0,0 @@
package com.github.javafaker;
public class LordOfTheRings {
private final Faker faker;
protected LordOfTheRings(final Faker faker) {
this.faker = faker;
}
public String character() {
return faker.resolve("lord_of_the_rings.characters");
}
public String location() {
return faker.resolve("lord_of_the_rings.locations");
}
}

View File

@ -1,176 +0,0 @@
package com.github.javafaker;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import static org.apache.commons.lang3.StringUtils.capitalize;
import static org.apache.commons.lang3.StringUtils.join;
public class Lorem {
private final Faker faker;
protected Lorem(Faker faker) {
this.faker = faker;
}
public char character() {
return character(false);
}
public char character(boolean includeUppercase) {
return characters(1, includeUppercase).charAt(0);
}
public String characters() {
return characters(255, false);
}
public String characters(boolean includeUppercase) {
return characters(255, includeUppercase);
}
public String characters(int minimumLength, int maximumLength) {
return characters(faker.random().nextInt(maximumLength - minimumLength) + minimumLength, false);
}
public String characters(int minimumLength, int maximumLength, boolean includeUppercase) {
return characters(faker.random().nextInt(maximumLength - minimumLength) + minimumLength, includeUppercase);
}
public String characters(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeDigit) {
return characters(faker.random().nextInt(maximumLength - minimumLength) + minimumLength, includeUppercase, includeDigit);
}
public String characters(int fixedNumberOfCharacters) {
return characters(fixedNumberOfCharacters, false);
}
public String characters(int fixedNumberOfCharacters, boolean includeUppercase) {
return characters(fixedNumberOfCharacters, includeUppercase, true);
}
public String characters(int fixedNumberOfCharacters, boolean includeUppercase, boolean includeDigit) {
if (fixedNumberOfCharacters < 1) {
return "";
}
char[] buffer = new char[fixedNumberOfCharacters];
for (int i = 0; i < buffer.length; i++) {
char randomCharacter;
if (includeDigit) {
randomCharacter = characters[faker.random().nextInt(characters.length)];
} else {
randomCharacter = letters[faker.random().nextInt(letters.length)];
}
if (includeUppercase && faker.bool().bool()) {
randomCharacter = Character.toUpperCase(randomCharacter);
}
buffer[i] = randomCharacter;
}
return new String(buffer);
}
public List<String> words(int num) {
List<String> returnList = new ArrayList<String>();
for (int i = 0; i < num; i++) {
returnList.add(word());
}
return returnList;
}
public List<String> words() {
return words(3);
}
public String word() {
return faker.fakeValuesService().resolve("lorem.words", this, faker);
}
/**
* Create a sentence with a random number of words within the range 4..10.
* @return a random sentence
*/
public String sentence() {
return sentence(3);
}
/**
* Create a sentence with a random number of words within the range (wordCount+1)..(wordCount+6).
* @param wordCount
* @return a random sentence
*/
public String sentence(int wordCount) {
return sentence(wordCount, 6);
}
/**
* Create a sentence with a random number of words within the range (wordCount+1)..(wordCount+randomWordsToAdd).</p>
*
* Set {@code randomWordsToAdd} to 0 to generate sentences with a fixed number of words.
* @param wordCount
* @param randomWordsToAdd
* @return a random sentence
*/
public String sentence(int wordCount, int randomWordsToAdd) {
int numberOfWordsToAdd = randomWordsToAdd == 0 ? 0 : faker.random().nextInt(randomWordsToAdd);
return capitalize(join(words(wordCount + numberOfWordsToAdd), " ") + ".");
}
public List<String> sentences(int sentenceCount) {
List<String> sentences = new ArrayList<String>(sentenceCount);
for (int i = 0; i < sentenceCount; i++) {
sentences.add(sentence());
}
return sentences;
}
public String paragraph(int sentenceCount) {
return join(sentences(sentenceCount + faker.random().nextInt(3)), " ");
}
public String paragraph() {
return paragraph(3);
}
public List<String> paragraphs(int paragraphCount) {
List<String> paragraphs = new ArrayList<String>(paragraphCount);
for (int i = 0; i < paragraphCount; i++) {
paragraphs.add(paragraph());
}
return paragraphs;
}
/**
* Create a string with a fixed size. Can be useful for testing
* validator based on length string for example
*
* @param numberOfLetters size of the expected String
* @return a string with a fixed size
*/
public String fixedString(int numberOfLetters) {
StringBuilder builder = new StringBuilder();
while (builder.length() < numberOfLetters) {
builder.append(sentence());
}
return StringUtils.substring(builder.toString(), 0, numberOfLetters);
}
static {
StringBuilder builder = new StringBuilder(36);
for (char character = 'a'; character <= 'z'; character++) {
builder.append(character);
}
letters = builder.toString().toCharArray();
for (char number = '0'; number <= '9'; number++) {
builder.append(number);
}
characters = builder.toString().toCharArray();
}
private static final char[] letters;
private static final char[] characters;
}

View File

@ -1,13 +0,0 @@
package com.github.javafaker;
public class Matz {
private final Faker faker;
protected Matz(final Faker faker) {
this.faker = faker;
}
public String quote() {
return faker.resolve("matz.quotes");
}
}

View File

@ -1,26 +0,0 @@
package com.github.javafaker;
public class Medical {
private final Faker faker;
protected Medical(Faker faker) {
this.faker = faker;
}
public String medicineName() {
return faker.fakeValuesService().resolve("medical.medicine_name", this, faker);
}
public String diseaseName() {
return faker.fakeValuesService().resolve("medical.disease_name", this, faker);
}
public String hospitalName() {
return faker.fakeValuesService().resolve("medical.hospital_name", this, faker);
}
public String symptoms() {
return faker.fakeValuesService().resolve("medical.symptoms", this, faker);
}
}

View File

@ -1,17 +0,0 @@
package com.github.javafaker;
public class Mountain {
private final Faker faker;
protected Mountain(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("mountain.name", this, faker);
}
public String range() {
return faker.fakeValuesService().resolve("mountain.range", this, faker);
}
}

View File

@ -1,30 +0,0 @@
package com.github.javafaker;
public class Music {
private static final String[] KEYS = new String[] { "C", "D", "E", "F", "G", "A", "B" };
private static final String[] KEY_VARIANTS = new String[] { "b", "#", "" };
private static final String[] CHORD_TYPES = new String[] { "", "maj", "6", "maj7", "m", "m7", "-7", "7", "dom7", "dim", "dim7", "m7b5"};
private final Faker faker;
protected Music(Faker faker) {
this.faker = faker;
}
public String instrument() {
return faker.resolve("music.instruments");
}
public String key() {
return faker.options().option(KEYS) + faker.options().option(KEY_VARIANTS);
}
public String chord() {
return key() + faker.options().option(CHORD_TYPES);
}
public String genre() {
return faker.resolve("music.genres");
}
}

View File

@ -1,140 +0,0 @@
package com.github.javafaker;
import org.apache.commons.lang3.StringUtils;
public class Name {
private final Faker faker;
/**
* Internal constructor, not to be used by clients. Instances of {@link Name} should be accessed via
* {@link Faker#name()}.
*/
protected Name(Faker faker) {
this.faker = faker;
}
/**
* <p>
* A multipart name composed of an optional prefix, a firstname and a lastname
* or other possible variances based on locale. Examples:
* <ul>
* <li>James Jones Jr.</li>
* <li>Julie Johnson</li>
* </ul>
* </p>
* @return a random name with given and family names and an optional suffix.
*/
public String name() {
return faker.fakeValuesService().resolve("name.name", this, faker);
}
/**
* <p>
* A multipart name composed of an optional prefix, a given and family name,
* another 'firstname' for the middle name and an optional suffix such as Jr.
* Examples:
* <ul>
* <li>Mrs. Ella Geraldine Fitzgerald</li>
* <li>Jason Tom Sawyer Jr.</li>
* <li>Helen Jessica Troy</li>
* </ul>
* </p>
* @return a random name with a middle name component with optional prefix and suffix
*/
public String nameWithMiddle() {
return faker.fakeValuesService().resolve("name.name_with_middle", this, faker);
}
/**
* <p>Returns the same value as {@link #name()}</p>
* @see Name#name()
*/
public String fullName() {
return name();
}
/**
* <p>Returns a random 'given' name such as Aaliyah, Aaron, Abagail or Abbey</p>
* @return a 'given' name such as Aaliyah, Aaron, Abagail or Abbey
*/
public String firstName() {
return faker.fakeValuesService().resolve("name.first_name", this, faker);
}
/**
* <p>Returns a random last name such as Smith, Jones or Baldwin</p>
* @return a random last name such as Smith, Jones or Baldwin
*/
public String lastName() {
return faker.fakeValuesService().resolve("name.last_name", this, faker);
}
/**
* <p>Returns a name prefix such as Mr., Mrs., Ms., Miss, or Dr.</p>
* @return a name prefix such as Mr., Mrs., Ms., Miss, or Dr.
*/
public String prefix() {
return faker.fakeValuesService().resolve("name.prefix", this, faker);
}
/**
* <p>Returns a name suffix such as Jr., Sr., I, II, III, IV, V, MD, DDS, PhD or DVM</p>
* @return a name suffix such as Jr., Sr., I, II, III, IV, V, MD, DDS, PhD or DVM
*/
public String suffix() {
return faker.fakeValuesService().resolve("name.suffix", this, faker);
}
/**
* <p>
* A three part title composed of a descriptor level and job. Some examples are :
* <ul>
* <li>(template) {descriptor} {level} {job}</li>
* <li>Lead Solutions Specialist</li>
* <li>National Marketing Manager</li>
* <li>Central Response Liaison</li>
* </ul>
* </p>
* @return a random three part job title
*/
public String title() {
return StringUtils.join(new String[] {
faker.fakeValuesService().resolve("name.title.descriptor", this, faker),
faker.fakeValuesService().resolve("name.title.level", this, faker),
faker.fakeValuesService().resolve("name.title.job", this, faker) }, " ");
}
/**
* <p>
* A lowercase username composed of the first_name and last_name joined with a '.'. Some examples are:
* <ul>
* <li>(template) {@link #firstName()}.{@link #lastName()}</li>
* <li>jim.jones</li>
* <li>jason.leigh</li>
* <li>tracy.jordan</li>
* </ul>
* </p>
* @return a random two part user name.
* @see Name#firstName()
* @see Name#lastName()
*/
public String username() {
String username = StringUtils.join(
firstName().replaceAll("'", "").toLowerCase(),
".",
lastName().replaceAll("'", "").toLowerCase()
);
return StringUtils.deleteWhitespace(username);
}
/**
* <p>Returns a blood group such as O, O+, A-, A+, B-, B+, AB-, AB+</p>
* @return a blood group such as O, O+, A-, A+, B-, B+, AB-, AB+
*/
public String bloodGroup() {
return faker.fakeValuesService().resolve("name.blood_group", this, faker);
}
}

View File

@ -1,43 +0,0 @@
package com.github.javafaker;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.charset.Charset;
import java.util.List;
public class Nation {
private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
private final Faker faker;
protected Nation(Faker faker) {
this.faker = faker;
}
public String nationality() {
return faker.fakeValuesService().resolve("nation.nationality", this, faker);
}
public String language() {
return faker.fakeValuesService().resolve("nation.language", this, faker);
}
public String capitalCity() {
return faker.fakeValuesService().resolve("nation.capital_city", this, faker);
}
public String flag() {
@SuppressWarnings("unchecked")
List<Integer> flagInts = (List<Integer>) faker.fakeValuesService().fetch("nation.flag");
ByteBuffer byteBuffer = MappedByteBuffer.allocate(flagInts.size());
for (Integer flagInt : flagInts) {
byteBuffer.put(flagInt.byteValue());
}
return new String(byteBuffer.array(), UTF8_CHARSET);
}
}

View File

@ -1,123 +0,0 @@
package com.github.javafaker;
import java.math.BigDecimal;
public class Number {
private final Faker faker;
protected Number(Faker faker) {
this.faker = faker;
}
/**
* Returns a random number from 0-9 (both inclusive)
*/
public int randomDigit() {
return decimalBetween(0,10).intValue();
}
/**
* Returns a random number from 1-9 (both inclusive)
*/
public int randomDigitNotZero() {
return decimalBetween(1,10).intValue();
}
/**
* @see Number#numberBetween(long, long)
*/
public int numberBetween(int min, int max) {
if (min == max) return min;
int value = decimalBetween(min,max).setScale(0, BigDecimal.ROUND_HALF_DOWN).intValue();
return value == max ? value - 1 : value;
}
/**
* Return a number between <em>min</em> and <em>max</em>. If
* min == max, then min is returned. So numberBetween(2,2) will yield 2 even though
* it doesn't make sense.
*
* @param min inclusive
* @param max exclusive (unless min == max)
*/
public long numberBetween(long min, long max) {
if (min == max) return min;
long value = decimalBetween(min, max).setScale(0, BigDecimal.ROUND_HALF_DOWN).longValue();
return value == max ? value - 1 : value;
}
/**
* @param numberOfDigits the number of digits the generated value should have
* @param strict whether or not the generated value should have exactly <code>numberOfDigits</code>
*/
public long randomNumber(int numberOfDigits, boolean strict) {
long max = (long) Math.pow(10, numberOfDigits);
if (strict) {
long min = (long) Math.pow(10, numberOfDigits - 1);
return faker.random().nextLong(max - min) + min;
}
return faker.random().nextLong(max);
}
/**
* Returns a random number
*/
public long randomNumber() {
int numberOfDigits = decimalBetween(1,10).intValue();
return randomNumber(numberOfDigits, false);
}
public double randomDouble(int maxNumberOfDecimals, int min, int max) {
return randomDouble(maxNumberOfDecimals,(long) min, (long) max);
}
/**
* Returns a random double
*
* @param maxNumberOfDecimals maximum number of places
* @param min minimum value
* @param max maximum value
*/
public double randomDouble(int maxNumberOfDecimals, long min, long max) {
return decimalBetween(min,max)
.setScale(maxNumberOfDecimals, BigDecimal.ROUND_HALF_DOWN)
.doubleValue();
}
/**
* @param min inclusive
* @param max exclusive
* @return
*/
private BigDecimal decimalBetween(long min, long max) {
if (min == max) {
return new BigDecimal(min);
}
final long trueMin = Math.min(min, max);
final long trueMax = Math.max(min, max);
final double range = (double) trueMax - (double) trueMin;
final double chunkCount = Math.sqrt(Math.abs(range));
final double chunkSize = chunkCount;
final long randomChunk = faker.random().nextLong((long) chunkCount);
final double chunkStart = trueMin + randomChunk * chunkSize;
final double adj = chunkSize * faker.random().nextDouble();
return new BigDecimal(chunkStart + adj);
}
public String digits(int count) {
final StringBuilder tmp = new StringBuilder();
for (int i = 0; i < count; i++) {
tmp.append(randomDigit());
}
return tmp.toString();
}
public String digit() {
return digits(1);
}
}

View File

@ -1,55 +0,0 @@
package com.github.javafaker;
import java.util.List;
public class Options {
private final Faker faker;
protected Options(Faker faker) {
this.faker = faker;
}
/**
* Returns a random element from an varargs.
*
* @param options The varargs to take a random element from.
* @param <E> The type of the elements in the varargs.
* @return A randomly selected element from the varargs.
*/
public <E> E option(E... options) {
return options[faker.random().nextInt(options.length)];
}
/**
* Returns a random element from Enum.
*
* @param enumeration The Enum to take a random element from.
* @return A randomly selected element from the enum.
*/
public <E extends Enum<E>> E option(Class<E> enumeration) {
E[] enumConstants = enumeration.getEnumConstants();
return enumConstants[faker.random().nextInt(enumConstants.length)];
}
/**
* Returns a random element from an array.
*
* @param array The array to take a random element from.
* @param <E> The type of the elements in the array.
* @return A randomly selected element from the array.
*/
public <E> E nextElement(E[] array) {
return array[faker.random().nextInt(array.length)];
}
/**
* Returns a random element from a list.
*
* @param list The list to take a random element from.
* @param <E> The type of the elements in the list.
* @return A randomly selected element from the list.
*/
public <E> E nextElement(List<E> list) {
return list.get(faker.random().nextInt(list.size()));
}
}

View File

@ -1,21 +0,0 @@
package com.github.javafaker;
public class Overwatch {
private final Faker faker;
protected Overwatch(Faker faker) {
this.faker = faker;
}
public String hero() {
return faker.fakeValuesService().resolve("games.overwatch.heroes", this, faker);
}
public String location() {
return faker.fakeValuesService().resolve("games.overwatch.locations", this, faker);
}
public String quote() {
return faker.fakeValuesService().resolve("games.overwatch.quotes", this, faker);
}
}

View File

@ -1,33 +0,0 @@
package com.github.javafaker;
public class PhoneNumber {
private final Faker faker;
protected PhoneNumber(Faker faker) {
this.faker = faker;
}
public String cellPhone() {
return faker.numerify(faker.fakeValuesService().resolve("cell_phone.formats", this, faker));
}
public String phoneNumber() {
return faker.numerify(faker.fakeValuesService().resolve("phone_number.formats", this, faker));
}
public String extension() {
return subscriberNumber();
}
public String subscriberNumber(int length) {
StringBuilder subscriberNumber = new StringBuilder();
for (int i = 0; i < length; i++) {
subscriberNumber.append("#");
}
return faker.numerify(subscriberNumber.toString());
}
public String subscriberNumber() {
return subscriberNumber(4);
}
}

View File

@ -1,76 +0,0 @@
package com.github.javafaker;
/**
* Provides photography related strings.
*/
public class Photography {
private final Faker faker;
protected Photography(Faker faker) {
this.faker = faker;
}
/**
* @return a photography term.
*/
public String term() {
return faker.fakeValuesService().fetchString("photography.term");
}
/**
* @return a photography brand.
*/
public String brand() {
return faker.fakeValuesService().fetchString("photography.brand");
}
/**
* @return a name of camera model/make.
*/
public String camera() {
return faker.fakeValuesService().fetchString("photography.camera");
}
/**
* @return some lens description like 500mm/8.
*/
public String lens() {
return faker.fakeValuesService().fetchString("photography.lens");
}
/**
* @return a photography genre.
*/
public String genre() {
return faker.fakeValuesService().fetchString("photography.genre");
}
/**
* @return some string to tag an image.
*/
public String imageTag() {
return faker.fakeValuesService().fetchString("photography.imagetag");
}
/**
* @return some aperture description like f/1.4 .
*/
public String aperture() {
return faker.fakeValuesService().fetchString("photography.aperture");
}
/**
* @return some shutter description like 1/25 .
*/
public String shutter() {
return faker.fakeValuesService().fetchString("photography.shutter");
}
/**
* @return some ISO value like 3200.
*/
public String iso() {
return faker.fakeValuesService().fetchString("photography.iso");
}
}

View File

@ -1,18 +0,0 @@
package com.github.javafaker;
public class Pokemon {
private final Faker faker;
protected Pokemon(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.resolve("games.pokemon.names");
}
public String location() {
return faker.resolve("games.pokemon.locations");
}
}

View File

@ -1,17 +0,0 @@
package com.github.javafaker;
public class PrincessBride {
private final Faker faker;
protected PrincessBride(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.resolve("princess_bride.characters");
}
public String quote() {
return faker.resolve("princess_bride.quotes");
}
}

View File

@ -1,19 +0,0 @@
package com.github.javafaker;
public class ProgrammingLanguage {
private final Faker faker;
public ProgrammingLanguage(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("programming_language.name", this, faker);
}
public String creator() {
return faker.fakeValuesService().resolve("programming_language.creator", this, faker);
}
}

View File

@ -1,60 +0,0 @@
package com.github.javafaker;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.commons.lang3.ArrayUtils;
public class Relationships {
private final Faker faker;
protected Relationships(final Faker faker) {
this.faker = faker;
}
public String direct() {
return faker.resolve("relationship.familial.direct");
}
public String extended() {
return faker.resolve("relationship.familial.extended");
}
public String inLaw() {
return faker.resolve("relationship.in_law");
}
public String spouse() {
return faker.resolve("relationship.spouse");
}
public String parent() {
return faker.resolve("relationship.parent");
}
public String sibling() {
return faker.resolve("relationship.sibling");
}
public String any() {
Method currentMethod = getClass().getEnclosingMethod();
try {
Method[] methods = Relationships.class.getDeclaredMethods();
methods = ArrayUtils.removeElement(methods, currentMethod);
int indx = faker.random().nextInt(methods.length);
Method runMethod = methods[indx];
Relationships relationships = new Relationships(faker);
return (String)runMethod.invoke(relationships);
} catch (SecurityException e) {
throw new RuntimeException("SecurityException: " + e.getMessage());
} catch (IllegalArgumentException e) {
throw new RuntimeException("IllegalArgumentException: " + e.getMessage());
} catch (IllegalAccessException e) {
throw new RuntimeException("IllegalAccessException: " + e.getMessage());
} catch (InvocationTargetException e) {
throw new RuntimeException("InvocationTargetException: " + e.getMessage());
}
}
}

View File

@ -1,21 +0,0 @@
package com.github.javafaker;
public class RickAndMorty {
private final Faker faker;
protected RickAndMorty(final Faker faker) {
this.faker = faker;
}
public String character() {
return faker.resolve("rick_and_morty.characters");
}
public String location() {
return faker.resolve("rick_and_morty.locations");
}
public String quote() {
return faker.resolve("rick_and_morty.quotes");
}
}

View File

@ -1,13 +0,0 @@
package com.github.javafaker;
public class Robin {
private final Faker faker;
protected Robin(Faker faker) {
this.faker = faker;
}
public String quote() {
return faker.fakeValuesService().resolve("robin.quotes", this, faker);
}
}

View File

@ -1,14 +0,0 @@
package com.github.javafaker;
public class RockBand {
private final Faker faker;
protected RockBand(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.resolve("rock_band.name");
}
}

View File

@ -1,85 +0,0 @@
package com.github.javafaker;
public class Shakespeare {
private static final String [] hamletQuotes = {
"To be, or not to be: that is the question.",
"Neither a borrower nor a lender be; For loan oft loses both itself and friend, and borrowing dulls the edge of husbandry.",
"This above all: to thine own self be true.",
"Though this be madness, yet there is method in 't.",
"That it should come to this!.",
"There is nothing either good or bad, but thinking makes it so.",
"What a piece of work is man! how noble in reason! how infinite in faculty! in form and moving how express and admirable! in action how like an angel! in apprehension how like a god! the beauty of the world, the paragon of animals! .",
"The lady doth protest too much, methinks.",
"In my mind's eye.",
"A little more than kin, and less than kind.",
"The play 's the thing wherein I'll catch the conscience of the king.",
"And it must follow, as the night the day, thou canst not then be false to any man.",
"Brevity is the soul of wit.",
"Doubt that the sun doth move, doubt truth to be a liar, but never doubt I love.",
"Rich gifts wax poor when givers prove unkind.",
"Do you think I am easier to be played on than a pipe?",
"I will speak daggers to her, but use none.",
"When sorrows come, they come not single spies, but in battalions." };
private static final String [] asYouLikeItQuotes = {
"All the world 's a stage, and all the men and women merely players. They have their exits and their entrances; And one man in his time plays many parts.",
"Can one desire too much of a good thing?.",
"I like this place and willingly could waste my time in it.",
"How bitter a thing it is to look into happiness through another man's eyes!",
"Blow, blow, thou winter wind! Thou art not so unkind as man's ingratitude.",
"True is it that we have seen better days.",
"For ever and a day.",
"The fool doth think he is wise, but the wise man knows himself to be a fool." };
private static final String [] kingRichardIIIQuotes = {
"Now is the winter of our discontent.",
"A horse! a horse! my kingdom for a horse!.",
"Conscience is but a word that cowards use, devised at first to keep the strong in awe.",
"So wise so young, they say, do never live long.",
"Off with his head!",
"An honest tale speeds best, being plainly told.",
"The king's name is a tower of strength.",
"The world is grown so bad, that wrens make prey where eagles dare not perch." };
private static final String [] romeoAndJulietQuotes = {
"O Romeo, Romeo! wherefore art thou Romeo?.",
"It is the east, and Juliet is the sun.",
"Good Night, Good night! Parting is such sweet sorrow, that I shall say good night till it be morrow.",
"What's in a name? That which we call a rose by any other name would smell as sweet.",
"Wisely and slow; they stumble that run fast.",
"Tempt not a desperate man.",
"For you and I are past our dancing days.",
"O! she doth teach the torches to burn bright.",
"It seems she hangs upon the cheek of night like a rich jewel in an Ethiope's ear.",
"See, how she leans her cheek upon her hand! O that I were a glove upon that hand, that I might touch that cheek!.",
"Not stepping o'er the bounds of modesty." };
private final Faker faker;
protected Shakespeare(Faker faker) {
this.faker = faker;
}
public String hamletQuote() {
return randomElement(hamletQuotes);
}
public String asYouLikeItQuote() {
return randomElement(asYouLikeItQuotes);
}
public String kingRichardIIIQuote() {
return randomElement(kingRichardIIIQuotes);
}
public String romeoAndJulietQuote() {
return randomElement(romeoAndJulietQuotes);
}
private String randomElement(String[] values) {
return values[faker.random().nextInt(values.length)];
}
}

View File

@ -1,215 +0,0 @@
package com.github.javafaker;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.util.ArrayList;
/**
* Faker class for generating Session Initiation Protocol (SIP) related data.
*
* @author TomerFi
*/
public final class Sip {
private final Faker faker;
private final ArrayList<Integer> portPool;
protected Sip(final Faker faker) {
this.faker = faker;
int port = 40000;
portPool = new ArrayList<Integer>();
while (port <= 50000) {
portPool.add(port);
port = port + 2;
}
}
/**
* The various SIP methods are listed in https://en.wikipedia.org/wiki/Session_Initiation_Protocol.
*
* @return a SIP method String, e.g. {@code INVITE}.
*/
public String method() {
return faker.resolve("sip.methods");
}
/**
* Content types are based on https://tools.ietf.org/html/rfc5621 and
* https://tools.ietf.org/html/rfc3261.
*
* @return a SIP content-type declaration String, e.g. {@code application/sdp}
*/
public String contentType() {
return faker.resolve("sip.content.types");
}
/**
* Get a 4 digit random port for SIP messaging.
*
* @return a SIP messaging port int, e.g. 5060.
*/
public int messagingPort() {
return faker.random().nextInt(1000, 9999);
}
/**
* Get a 5 digit positive even port for rtp udp communication.
*
* @return an RTP UDP 5 digit port int, e.g. 40002.
*/
public int rtpPort() {
return portPool.get(faker.random().nextInt(0, portPool.size()));
}
/**
* Proviosional code, the various response codes are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a 3 digit SIP provisioan response code between 100 and 199 int, e.g. {@code 180}.
*/
public int provisionalResponseCode() {
return Integer.parseInt(faker.resolve("sip.response.codes.provisional"));
}
/**
* Success code, the various response codes are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a 3 digit SIP success response code between 200 and 299 int, e.g. {@code 200}.
*/
public int successResponseCode() {
return Integer.parseInt(faker.resolve("sip.response.codes.success"));
}
/**
* Redirection code, the various response codes are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a 3 digit SIP redirection response code between 300 and 399 int, e.g. {@code 301}.
*/
public int redirectResponseCode() {
return Integer.parseInt(faker.resolve("sip.response.codes.redirection"));
}
/**
* Client error code, the various response codes are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a 3 digit SIP client error response code between 400 and 499 int, e.g. {@code 486}.
*/
public int clientErrorResponseCode() {
return Integer.parseInt(faker.resolve("sip.response.codes.clientError"));
}
/**
* Server error code, the various response codes are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a 3 digit SIP server error response code between 500 and 599 int, e.g. {@code 503}.
*/
public int serverErrorResponseCode() {
return Integer.parseInt(faker.resolve("sip.response.codes.serverError"));
}
/**
* Global error code, the various response codes are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a 3 digit SIP global error response code between 600 and 699 int, e.g. {@code 608}.
*/
public int globalErrorResponseCode() {
return Integer.parseInt(faker.resolve("sip.response.codes.globalError"));
}
/**
* Proviosional phrase, the various response phrases are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a SIP provisional response phrase String, e.g. {@code Ringing}.
*/
public String provisionalResponsePhrase() {
return faker.resolve("sip.response.phrases.provisional");
}
/**
* Success phrase, the various response phrases are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a SIP success response phrase String, e.g. {@code OK}.
*/
public String successResponsePhrase() {
return faker.resolve("sip.response.phrases.success");
}
/**
* Redirection phrase, the various response phrases are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a SIP redirection response phrase String, e.g. {@code Moved Permanently}.
*/
public String redirectResponsePhrase() {
return faker.resolve("sip.response.phrases.redirection");
}
/**
* Client error phrase, the various response phrases are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a SIP client error response phrase String, e.g. {@code Busy Here}.
*/
public String clientErrorResponsePhrase() {
return faker.resolve("sip.response.phrases.clientError");
}
/**
* Server error phrase, the various response phrases are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a SIP server erro response phrase String, e.g. {@code Service Unavailable}.
*/
public String serverErrorResponsePhrase() {
return faker.resolve("sip.response.phrases.serverError");
}
/**
* Server error phrase, the various response phrases are listed in
* https://en.wikipedia.org/wiki/List_of_SIP_response_codes.
*
* @return a SIP global error response phrase String, e.g. {@code Rejected}.
*/
public String globalErrorResponsePhrase() {
return faker.resolve("sip.response.phrases.globalError");
}
/**
* Body example of SDP type can be found in https://tools.ietf.org/html/rfc5621.
*
* @return a fake SDP type SIP body String.
*/
public String bodyString() {
return "v=0\n" +
"o=" + faker.name().firstName() + " " + faker.internet().uuid() + " IN IP4 " + faker.internet().domainName() + "\n" +
"s=-\n" +
"c=IN IP4 " + faker.internet().ipV4Address() + "\n" +
"t=0 0\n" +
"m=audio " + rtpPort() + " RTP/AVP 0\n" +
"a=rtpmap:0 PCMU/8000";
}
/**
* Body example of SDP type can be found in https://tools.ietf.org/html/rfc5621.
*
* @return a fake SDP type SIP body byte array.
*/
public byte[] bodyBytes() {
return bodyString().getBytes(UTF_8);
}
/**
* Return a valid name address to use with {@code to/from} headers.
*
* @return a valid name address String, e.g. {@code <sip:fakeName@10.1.2.3:5060>}.
*/
public String nameAddress() {
return "<sip:" + faker.name().firstName() + "@" + faker.internet().ipV4Address() + ":" + messagingPort() + ">";
}
}

View File

@ -1,46 +0,0 @@
package com.github.javafaker;
public class SlackEmoji {
private final Faker faker;
protected SlackEmoji(Faker faker) {
this.faker = faker;
}
public String people() {
return faker.resolve("slack_emoji.people");
}
public String nature() {
return faker.resolve("slack_emoji.nature");
}
public String foodAndDrink() {
return faker.resolve("slack_emoji.food_and_drink");
}
public String celebration() {
return faker.resolve("slack_emoji.celebration");
}
public String activity() {
return faker.resolve("slack_emoji.activity");
}
public String travelAndPlaces() {
return faker.resolve("slack_emoji.travel_and_places");
}
public String objectsAndSymbols() {
return faker.resolve("slack_emoji.objects_and_symbols");
}
public String custom() {
return faker.resolve("slack_emoji.custom");
}
public String emoji() {
return faker.fakeValuesService().resolve("slack_emoji.emoji", this, faker);
}
}

View File

@ -1,62 +0,0 @@
package com.github.javafaker;
public class Space {
private final Faker faker;
protected Space(Faker faker) {
this.faker = faker;
}
public String planet() {
return faker.resolve("space.planet");
}
public String moon() {
return faker.resolve("space.moon");
}
public String galaxy() {
return faker.resolve("space.galaxy");
}
public String nebula() {
return faker.resolve("space.nebula");
}
public String starCluster() {
return faker.resolve("space.star_cluster");
}
public String constellation() {
return faker.resolve("space.constellation");
}
public String star() {
return faker.resolve("space.star");
}
public String agency() {
return faker.resolve("space.agency");
}
public String agencyAbbreviation() {
return faker.resolve("space.agency_abv");
}
public String nasaSpaceCraft() {
return faker.resolve("space.nasa_space_craft");
}
public String company() {
return faker.resolve("space.company");
}
public String distanceMeasurement() {
return faker.number().numberBetween(10, 100) + ' ' + faker.resolve("space.distance_measurement");
}
public String meteorite() {
return faker.resolve("space.meteorite");
}
}

View File

@ -1,27 +0,0 @@
package com.github.javafaker;
public class StarCraft {
private final Faker faker;
protected StarCraft(final Faker faker) {
this.faker = faker;
}
public String unit() {
return faker.fakeValuesService().resolve("starcraft.units", this, faker);
}
public String building() {
return faker.fakeValuesService().resolve("starcraft.buildings", this, faker);
}
public String character() {
return faker.fakeValuesService().resolve("starcraft.characters", this, faker);
}
public String planet() {
return faker.fakeValuesService().resolve("starcraft.planets", this, faker);
}
}

View File

@ -1,29 +0,0 @@
package com.github.javafaker;
public class StarTrek {
private final Faker faker;
protected StarTrek(Faker faker) {
this.faker = faker;
}
public String character() {
return faker.fakeValuesService().resolve("star_trek.character", this, faker);
}
public String location() {
return faker.fakeValuesService().resolve("star_trek.location", this, faker);
}
public String specie() {
return faker.fakeValuesService().resolve("star_trek.specie", this, faker);
}
public String villain() {
return faker.fakeValuesService().resolve("star_trek.villain", this, faker);
}
public String klingon() {
return faker.fakeValuesService().resolve("star_trek.klingon", this, faker);
}
}

View File

@ -1,19 +0,0 @@
package com.github.javafaker;
public class Stock {
private final Faker faker;
protected Stock(Faker faker) {
this.faker = faker;
}
public String nsdqSymbol() {
return faker.fakeValuesService().resolve("stock.symbol_nsdq", this, faker);
}
public String nyseSymbol() {
return faker.fakeValuesService().resolve("stock.symbol_nyse", this, faker);
}
}

View File

@ -1,29 +0,0 @@
package com.github.javafaker;
public class Superhero {
private final Faker faker;
protected Superhero(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("superhero.name", this, faker);
}
public String prefix() {
return faker.fakeValuesService().resolve("superhero.prefix", this, faker);
}
public String suffix() {
return faker.fakeValuesService().resolve("superhero.suffix", this, faker);
}
public String power() {
return faker.fakeValuesService().resolve("superhero.power", this, faker);
}
public String descriptor() {
return faker.fakeValuesService().resolve("superhero.descriptor", this, faker);
}
}

View File

@ -1,25 +0,0 @@
package com.github.javafaker;
public class Team {
private final Faker faker;
protected Team(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("team.name", this, faker);
}
public String creature() {
return faker.fakeValuesService().resolve("team.creature", this, faker);
}
public String state() {
return faker.fakeValuesService().resolve("address.state", this, faker);
}
public String sport() {
return faker.fakeValuesService().resolve("team.sport", this, faker);
}
}

View File

@ -1,21 +0,0 @@
package com.github.javafaker;
public class TwinPeaks {
private final Faker faker;
protected TwinPeaks(final Faker faker) {
this.faker = faker;
}
public String character() {
return faker.resolve("twin_peaks.characters");
}
public String location() {
return faker.resolve("twin_peaks.locations");
}
public String quote() {
return faker.resolve("twin_peaks.quotes");
}
}

View File

@ -1,21 +0,0 @@
package com.github.javafaker;
public class University {
private final Faker faker;
protected University(Faker faker) {
this.faker = faker;
}
public String name() {
return faker.fakeValuesService().resolve("university.name", this, faker);
}
public String prefix() {
return faker.fakeValuesService().resolve("university.prefix", this, faker);
}
public String suffix() {
return faker.fakeValuesService().resolve("university.suffix", this, faker);
}
}

View File

@ -1,65 +0,0 @@
package com.github.javafaker;
/**
* A generator for Weather data.
*/
public class Weather {
private static final int DEFAULT_MIN_TEMP_C = -30;
private static final int DEFAULT_MAX_TEMP_C = 38;
private static final int DEFAULT_MIN_TEMP_F = -22;
private static final int DEFAULT_MAX_TEMP_F = 100;
private final Faker faker;
protected Weather(Faker faker) {
this.faker = faker;
}
/**
* Generates a short weather description.
*/
public String description() {
return faker.resolve("weather.description");
}
/**
* Generates a random temperature celsius between -30 and 38 degrees.
* @return String that represents temperature in format 5°C
*/
public String temperatureCelsius() {
return temperature(DEFAULT_MIN_TEMP_C, DEFAULT_MAX_TEMP_C, "weather.temperature.celsius");
}
/**
* Generates a random temperature fahrenheit between -22 and 100 degrees.
* @return String that represents temperature in format 5°F
*/
public String temperatureFahrenheit() {
return temperature(DEFAULT_MIN_TEMP_F, DEFAULT_MAX_TEMP_F, "weather.temperature.fahrenheit");
}
/**
* Generates a random temperature celsius between two temperatures.
* @param minTemperature the minimal temperature
* @param maxTemperature the maximal temperature
* @return String that represents temperature in format 5°C
*/
public String temperatureCelsius(int minTemperature, int maxTemperature) {
return temperature(minTemperature, maxTemperature, "weather.temperature.celsius");
}
/**
* Generates a random temperature fahrenheit between two temperatures.
* @param minTemperature the minimal temperature
* @param maxTemperature the maximal temperature
* @return String that represents temperature in format 5°F
*/
public String temperatureFahrenheit(int minTemperature, int maxTemperature) {
return temperature(minTemperature, maxTemperature, "weather.temperature.fahrenheit");
}
private String temperature(int minTemperature, int maxTemperature, String degreeKey) {
return faker.random().nextInt(minTemperature, maxTemperature) + faker.resolve(degreeKey);
}
}

Some files were not shown because too many files have changed in this diff Show More