The slugger itself has no options. The reason for that is to only provide immutable objects as public API. This will prevent multithread related problems.
The only “runtime” option you can pass to the slugger is the used separator:
final Slug slugger = ...; // Default separator: final String url1 = slugger.get("..."); // Custom separator: final String url2 = slugger.get("...", "*");
Keep in mind that the latter call will overwrite the separator set to the builder options.
The basic principle how to configure and create a slugger is based on the builder pattern. That means that you can’t create an instance of Slug by yourself. You must use Slug.Builder for that.
Create a slugger with default options:
final Slug slugger = Slug.Builder.newBuiler().create();
Create a slugger with some options:
final Slug slugger = Slug.Builder.newBuiler() .separator("_") .maintainCase(true) .uricNoSlash(true) .create();
Keep in mind that each call to Builder#create() will create a new immutable instance.
If you change the options of the builder, any yet created sluggers will not chnage their behaviour:
final Slug.Builder creator = Slug.Builder.newBuiler(); final Slug slugger1 = creator.separator("_").create(); // Will not affect slugger1! final Slug slugger2 = creator.separator("*").create();
All methods to set an option returns the builder itself for method chaining.
Note: default only Base64 characters are allowed (/A-Za-z0-9_-/), setting uric, uricNoSlash or/and mark to true will add the specified chars to the allowed characters. The separator character is always allowed.