Skip to content

afrunt/random-joke-crawler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Java library for getting random jokes from different sources

Add random-joke-crawler to your project. for maven projects just add this dependency:

<dependency>
  <groupId>com.afrunt.randomjoke</groupId>
  <artifactId>random-joke-crawler</artifactId>
  <version>0.1.8</version>
</dependency>

It is extremely easy to initialize and start working with crawler:

Jokes jokes = new Jokes()
                 .withDefaultSuppliers();

jokes.randomJoke().ifPresent(joke -> System.out.println(joke.getText()));

You can customize the sources of jokes:

Jokes jokes = new Jokes()
                .withDefaultSuppliers()
                .with(BashOrg.class);

Or you can define your own set of sources:

Jokes jokes = new Jokes()
                .with(BashOrg.class, ChuckNorris.class);

Create your own source by extending the AbstractJokeSupplier:

public class MyJokes extends AbstractJokeSupplier {
    @Override
    public Joke get() {
        return new Joke().setText("The best joke ever");
    }

    @Override
    public String getSource() {
        return "my.joke";
    }
}

And add those source using:

Jokes jokes = new Jokes()
                .with(MyJokes.class);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages