Skip to content

khurozov/jokeapi-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JokeAPI Java

Java wrapper for JokeApi of Sv443

Installation

Add Maven dependency

<dependency>
    <groupId>uz.khurozov</groupId>
    <artifactId>jokeapi-java</artifactId>
    <version>1.0</version>
</dependency>

Usage example

JokeApi jokeApi = new JokeApi();

// Forming filter:

JokeFilter filter = new JokeFilter.Builder()
                .category(Category.Programming)
                .blacklistFlags(Set.of(Flag.nsfw, Flag.racist))
                .lang(Lang.en)
                .idRange(0, 305)
                .contains("Java")
                .type(Type.twopart)
                .build();

// Requesting joke(s):

Joke joke = jokeApi.getJoke(filter);
// or
List<Joke> jokes = jokeApi.getJokes(filter, 2);

// Printing joke:

System.out.println(joke.jokeString());