Package org.eclipse.sisu.plexus
Class Roles
- java.lang.Object
-
- org.eclipse.sisu.plexus.Roles
-
public final class Roles extends java.lang.Object
Utility methods for dealing with Plexus roles.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
MISSING_COMPONENT_ERROR
private static java.lang.String
MISSING_COMPONENT_WITH_HINT_ERROR
-
Constructor Summary
Constructors Modifier Constructor Description private
Roles()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
camelizeName(java.lang.String name)
Removes any dashes from the name and converts it to camelCase.static java.lang.String
canonicalRoleHint(java.lang.String role, java.lang.String hint)
Returns the canonical form of the given Plexus role-hint.static java.lang.String
canonicalRoleHint(org.codehaus.plexus.component.annotations.Component component)
Returns the canonical role-hint for the given Plexus component.static <T> com.google.inject.Key<T>
componentKey(com.google.inject.TypeLiteral<T> role, java.lang.String hint)
Returns the component bindingKey
for the given Plexus role-hint.static <T> com.google.inject.Key<T>
componentKey(java.lang.Class<T> role, java.lang.String hint)
Returns the component bindingKey
for the given Plexus role-hint.static com.google.inject.Key<?>
componentKey(org.codehaus.plexus.component.annotations.Component component)
Returns the component bindingKey
for the given Plexus component.static com.google.inject.TypeLiteral<?>
roleType(org.codehaus.plexus.component.annotations.Requirement requirement, com.google.inject.TypeLiteral<?> asType)
Deduces the role type based on the given @Requirement
and expected type.static <T> T
throwMissingComponentException(com.google.inject.TypeLiteral<T> role, java.lang.String hint)
Throws aProvisionException
detailing the missing Plexus component.
-
-
-
Field Detail
-
MISSING_COMPONENT_ERROR
private static final java.lang.String MISSING_COMPONENT_ERROR
- See Also:
- Constant Field Values
-
MISSING_COMPONENT_WITH_HINT_ERROR
private static final java.lang.String MISSING_COMPONENT_WITH_HINT_ERROR
- See Also:
- Constant Field Values
-
-
Method Detail
-
canonicalRoleHint
public static java.lang.String canonicalRoleHint(java.lang.String role, java.lang.String hint)
Returns the canonical form of the given Plexus role-hint.- Parameters:
role
- The Plexus rolehint
- The Plexus hint- Returns:
- Canonical role-hint denoting the same component as the given role-hint
-
canonicalRoleHint
public static java.lang.String canonicalRoleHint(org.codehaus.plexus.component.annotations.Component component)
Returns the canonical role-hint for the given Plexus component.- Parameters:
component
- The Plexus component- Returns:
- Canonical role-hint denoting the given component
-
roleType
public static com.google.inject.TypeLiteral<?> roleType(org.codehaus.plexus.component.annotations.Requirement requirement, com.google.inject.TypeLiteral<?> asType)
Deduces the role type based on the given @Requirement
and expected type.- Parameters:
requirement
- The Plexus requirementasType
- The expected type- Returns:
- "Best-fit" role type
-
componentKey
public static com.google.inject.Key<?> componentKey(org.codehaus.plexus.component.annotations.Component component)
Returns the component bindingKey
for the given Plexus component.- Parameters:
component
- The Plexus component- Returns:
- Component binding key denoting the given component
-
componentKey
public static <T> com.google.inject.Key<T> componentKey(java.lang.Class<T> role, java.lang.String hint)
Returns the component bindingKey
for the given Plexus role-hint.- Parameters:
role
- The Plexus rolehint
- The Plexus hint- Returns:
- Component binding key denoting the given role-hint
-
componentKey
public static <T> com.google.inject.Key<T> componentKey(com.google.inject.TypeLiteral<T> role, java.lang.String hint)
Returns the component bindingKey
for the given Plexus role-hint.- Parameters:
role
- The Plexus rolehint
- The Plexus hint- Returns:
- Component binding key denoting the given role-hint
-
throwMissingComponentException
public static <T> T throwMissingComponentException(com.google.inject.TypeLiteral<T> role, java.lang.String hint)
Throws aProvisionException
detailing the missing Plexus component.- Parameters:
role
- The Plexus rolehint
- The Plexus hint
-
camelizeName
public static java.lang.String camelizeName(java.lang.String name)
Removes any dashes from the name and converts it to camelCase.- Parameters:
name
- The element name- Returns:
- CamelCased name with no dashes
-
-