Skip to content

Latest commit

 

History

History
85 lines (55 loc) · 1.34 KB

File metadata and controls

85 lines (55 loc) · 1.34 KB

icndb-java-api

Overview

Java API client for The Internet Chuck Norris Database (http://www.icndb.com/)

Usage

Init

Everyting depend on ICNDBClient client object

import net.joningi.icndb.ICNDBClient;

....

final ICNDBClient client = new ICNDBClient();

Get single joke by ID

import net.joningi.icndb.Joke;

...

Joke joke = client.getById(15);
System.out.println(joke.getId() + ": " + joke.getJoke());

Get single random joke

Joke randomJoke = client.getRandom();

Get n random joke

for (Joke j : client.getRandom(10)) {
	System.out.println(j.getId() + ": " + j.getJoke());
}

Changing the name of the main character

client.setFirstName("Bill");
client.setLastName("Clinton");

Joke randomJoke = client.getRandom();

client.clearName();

Fetching the number of jokes

System.out.println(client.getCount());

Fetching the list of joke categories

for (String category : client.getCategories()) {
	System.out.println(category);
}

Limiting categories

client.setExclude(Lists.newArrayList("explicit", "nerdy"));
Joke randomJoke = client.getRandom();
client.clearLimitAndExclude();

client.setLimitTo(Lists.newArrayList("explicit", "nerdy"));
Joke randomJoke = client.getRandom();
client.clearLimitAndExclude();