
net.datafaker.providers.base.File Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datafaker Show documentation
Show all versions of datafaker Show documentation
This library is a improved port of JavaFaker (as well as Ruby's stympy/faker gem and 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.
package net.datafaker.providers.base;
/**
* @since 0.8.0
*/
public class File extends AbstractProvider {
protected File(BaseProviders faker) {
super(faker);
}
public String extension() {
return resolve("file.extension");
}
public String mimeType() {
return 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(faker.getContext().getLocale()) : nameOrNull;
final String ext = extensionOrNull == null ? extension() : extensionOrNull;
return dir + sep + name + "." + ext;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy