public class ButtonBuilder extends Object implements Serializable
The builder uses sensible default settings that can be changed by using its methods. All methods return a reference to the builder itself, so method calls can be daisy-chained.
Example: String button = new ButtonBuilder().url(myUrl).toString();
Constructor and Description |
---|
ButtonBuilder() |
Modifier and Type | Method and Description |
---|---|
ButtonBuilder |
attribute(String attribute,
String value)
Adds a custom HTML attribute to the generated link tag.
|
ButtonBuilder |
button(ButtonType type)
Selects the button type to be used.
|
ButtonBuilder |
category(CategoryId category)
The category the thing is categorized with.
|
ButtonBuilder |
description(String description)
Description of the thing.
|
ButtonBuilder |
descriptionTruncate(String description)
Convenience method that automatically truncates the description to its maximum
accepted length.
|
ButtonBuilder |
hidden()
The thing shall not be listed at Flattr.
|
ButtonBuilder |
html5()
Generate a HTML5 compliant button.
|
ButtonBuilder |
language(LanguageId language)
Specifies the language the thing is published in.
|
ButtonBuilder |
popout(boolean popout)
Sets whether to override the popout default and show a popout when hovering with
the mouse over the button.
|
ButtonBuilder |
prefix(String prefix)
Sets a HTML5 key prefix.
|
ButtonBuilder |
revsharekey(String key)
Sets the revenue share key to be used.
|
ButtonBuilder |
style(String style)
CSS style to be used.
|
ButtonBuilder |
styleClass(String styleClass)
CSS class to be used.
|
ButtonBuilder |
tag(String tag)
A tag that further describes the thing.
|
ButtonBuilder |
tags(Collection<String> tags)
Convenience method that adds a collection of tags.
|
ButtonBuilder |
thing(Submission thing)
Initializes the builder based on the given
Submission . |
ButtonBuilder |
thing(Thing thing)
Initializes the builder based on the given
Thing . |
ButtonBuilder |
title(String title)
Title of the thing.
|
String |
toString()
Builds a button of the current setup.
|
ButtonBuilder |
url(String url)
Unique URL to the thing.
|
ButtonBuilder |
url(URL url)
Unique URL to the thing.
|
ButtonBuilder |
user(UserId user)
User who published the thing.
|
public ButtonBuilder()
public ButtonBuilder url(String url)
public ButtonBuilder url(URL url)
URL
objects.public ButtonBuilder user(UserId user)
public ButtonBuilder title(String title)
public ButtonBuilder description(String description)
public ButtonBuilder descriptionTruncate(String description)
public ButtonBuilder category(CategoryId category)
public ButtonBuilder language(LanguageId language)
public ButtonBuilder tag(String tag)
public ButtonBuilder tags(Collection<String> tags)
public ButtonBuilder revsharekey(String key)
public ButtonBuilder button(ButtonType type)
public ButtonBuilder popout(boolean popout)
popout
- true
: always show a popout, false
: never show a popoutpublic ButtonBuilder hidden()
public ButtonBuilder thing(Thing thing)
Thing
. This is a
convenience method to prepare a link to an existing Thing.public ButtonBuilder thing(Submission thing)
Submission
. This is a
convenience method to prepare an autosubmit of a thing. Invoke
user(UserId)
together with this method for a successful autosubmission.public ButtonBuilder style(String style)
public ButtonBuilder styleClass(String styleClass)
public ButtonBuilder attribute(String attribute, String value)
Attributes are added without further checks. It is your responsibility to take care for HTML compliance.
attribute
- HTML attribute to be addedvalue
- Value of that attribute. The builder takes care for proper HTML
escaping.public ButtonBuilder html5()
public ButtonBuilder prefix(String prefix)
prefix
- HTML5 key prefix. The string must start with "data-"Copyright © 2010–2017. All rights reserved.