Package org.jline.style
Class StyleBundleInvocationHandler
- java.lang.Object
-
- org.jline.style.StyleBundleInvocationHandler
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
class StyleBundleInvocationHandler extends java.lang.Object implements java.lang.reflect.InvocationHandler
StyleBundle
proxy invocation-handler to convert method calls into string styling.- Since:
- 3.4
- See Also:
StyleBundle
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
StyleBundleInvocationHandler.InvalidStyleBundleMethodException
Thrown when processingStyleBundle
method is found to be invalid.(package private) static class
StyleBundleInvocationHandler.InvalidStyleGroupException
Thrown when looking upStyleBundle.StyleGroup
on a type found to be missing or invalid.(package private) static class
StyleBundleInvocationHandler.StyleBundleMethodMissingDefaultStyleException
Thrown whenStyleBundle
method has missingStyleBundle.DefaultStyle
.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
log
private StyleResolver
resolver
private java.lang.Class<? extends StyleBundle>
type
-
Constructor Summary
Constructors Constructor Description StyleBundleInvocationHandler(java.lang.Class<? extends StyleBundle> type, StyleResolver resolver)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static <T extends StyleBundle>
Tcreate(StyleResolver resolver, java.lang.Class<T> type)
Internal factory-method.(package private) static <T extends StyleBundle>
Tcreate(StyleSource source, java.lang.Class<T> type)
Internal factory-method.private static java.lang.String
emptyToNull(java.lang.String value)
private static java.lang.String
getDefaultStyle(java.lang.reflect.Method method)
Returns the default-style for given method, ornull
if unable to determine.private static java.lang.String
getStyleGroup(java.lang.Class<?> type)
Returns the style group-name for given type, ornull
if unable to determine.private static java.lang.String
getStyleName(java.lang.reflect.Method method)
Returns the style-name for given method, ornull
if unable to determine.java.lang.Object
invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
java.lang.String
toString()
Slightly better logging for proxies.private static void
validate(java.lang.reflect.Method method)
ThrowsStyleBundleInvocationHandler.InvalidStyleBundleMethodException
if given method is not suitable.
-
-
-
Field Detail
-
log
private static final java.util.logging.Logger log
-
type
private final java.lang.Class<? extends StyleBundle> type
-
resolver
private final StyleResolver resolver
-
-
Constructor Detail
-
StyleBundleInvocationHandler
public StyleBundleInvocationHandler(java.lang.Class<? extends StyleBundle> type, StyleResolver resolver)
-
-
Method Detail
-
validate
private static void validate(java.lang.reflect.Method method)
ThrowsStyleBundleInvocationHandler.InvalidStyleBundleMethodException
if given method is not suitable.
-
emptyToNull
@Nullable private static java.lang.String emptyToNull(@Nullable java.lang.String value)
-
getStyleGroup
@Nullable private static java.lang.String getStyleGroup(java.lang.Class<?> type)
Returns the style group-name for given type, ornull
if unable to determine.
-
getStyleName
private static java.lang.String getStyleName(java.lang.reflect.Method method)
Returns the style-name for given method, ornull
if unable to determine.
-
getDefaultStyle
@Nullable private static java.lang.String getDefaultStyle(java.lang.reflect.Method method)
Returns the default-style for given method, ornull
if unable to determine.
-
create
static <T extends StyleBundle> T create(StyleResolver resolver, java.lang.Class<T> type)
Internal factory-method.- See Also:
Styler.bundle(Class)
-
create
static <T extends StyleBundle> T create(StyleSource source, java.lang.Class<T> type)
Internal factory-method.- See Also:
Styler.bundle(String, Class)
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
- Specified by:
invoke
in interfacejava.lang.reflect.InvocationHandler
- Throws:
java.lang.Throwable
-
toString
public java.lang.String toString()
Slightly better logging for proxies.- Overrides:
toString
in classjava.lang.Object
-
-