Package it.tidalwave.role.ui
Interface Displayable
-
- All Known Subinterfaces:
LocalizedDisplayable
,MutableDisplayable
,MutableLocalizedDisplayable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Displayable
The role of an object which can provide its own display name.- Author:
- Fabrizio Giudici
- Status: stable API
- Stereotype:
- Role
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Class<Displayable>
_Displayable_
static Displayable
DEFAULT
A defaultDisplayable
with an empty display name.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static java.util.Comparator<As>
asComparing()
Returns aComparator
for comparing two instances of objects implementingAs
that contain theDisplayable
role.static java.util.Comparator<Displayable>
comparing()
Returns aComparator
for comparing two instances ofDisplayable
.default void
display(java.util.function.Consumer<java.lang.String> consumer)
Sends the display name in the currentLocale
to a given customer.static LocalizedDisplayable
fromBundle(java.lang.Class<?> ownerClass, java.lang.String key)
Creates aLocalizedDisplayable
from a resource bundle.java.lang.String
getDisplayName()
Returns the display name in the currentLocale
.static Displayable
of(java.lang.String displayName)
Creates an instance with a given display name.static Displayable
of(java.lang.String displayName, java.lang.String toStringName)
Creates an instance with a given display name iand an explicit label fortoString()
.static <T> Displayable
of(java.util.function.Function<T,java.lang.String> function, T object)
Creates an instance from aFunction
<T, String>
and a generic object that the function is applied to.static Displayable
of(java.util.function.Supplier<java.lang.String> supplier)
Creates an instance from aSupplier
<String>
.
-
-
-
Field Detail
-
_Displayable_
static final java.lang.Class<Displayable> _Displayable_
-
DEFAULT
static final Displayable DEFAULT
A defaultDisplayable
with an empty display name.
-
-
Method Detail
-
getDisplayName
@Nonnull java.lang.String getDisplayName()
Returns the display name in the currentLocale
.- Returns:
- the display name
-
display
default void display(@Nonnull java.util.function.Consumer<java.lang.String> consumer)
Sends the display name in the currentLocale
to a given customer.- Parameters:
consumer
- theConsumer
- Since:
- 3.2-ALPHA-15
-
of
@Nonnull static Displayable of(@Nonnull java.lang.String displayName)
Creates an instance with a given display name.- Parameters:
displayName
- the display name- Returns:
- the new instance
- Since:
- 3.2-ALPHA-1 (was
DefaultDisplayable
-
of
@Nonnull static Displayable of(@Nonnull java.lang.String displayName, @Nonnull java.lang.String toStringName)
Creates an instance with a given display name iand an explicit label fortoString()
.- Parameters:
displayName
- the display nametoStringName
- the name to be rendered whentoString()
is called- Returns:
- the new instance
- Since:
- 3.2-ALPHA-1 (was
DefaultDisplayable
-
of
@Nonnull static Displayable of(@Nonnull java.util.function.Supplier<java.lang.String> supplier)
Creates an instance from aSupplier
<String>
. The supplier is invoked each timegetDisplayName()
is called.- Parameters:
supplier
- theSupplier
- Returns:
- the new instance
- Since:
- 3.2-ALPHA-3
-
of
@Nonnull static <T> Displayable of(@Nonnull java.util.function.Function<T,java.lang.String> function, @Nonnull T object)
Creates an instance from aFunction
<T, String>
and a generic object that the function is applied to. The function is invoked each timegetDisplayName()
is called.- Type Parameters:
T
- the type of the object- Parameters:
function
- theFunction
object
- the object- Returns:
- the new instance
- Since:
- 3.2-ALPHA-3
-
fromBundle
@Nonnull static LocalizedDisplayable fromBundle(@Nonnull java.lang.Class<?> ownerClass, @Nonnull java.lang.String key)
Creates aLocalizedDisplayable
from a resource bundle. The bundle resource file is namedBundle.properties
and it should be placed in the same package as the owner class.- Parameters:
ownerClass
- the class that owns the bundlekey
- the resource key- Returns:
- the new instance
- Since:
- 3.2-ALPHA-1 (was previously in
Displayable8
-
comparing
@Nonnull static java.util.Comparator<Displayable> comparing()
Returns aComparator
for comparing two instances ofDisplayable
.- Returns:
- the
Comparator
- Since:
- 3.2-ALPHA-6
-
asComparing
@Nonnull static java.util.Comparator<As> asComparing()
Returns aComparator
for comparing two instances of objects implementingAs
that contain theDisplayable
role.- Returns:
- the
Comparator
- Since:
- 3.2-ALPHA-6
-
-