Skip to content

Commit

Permalink
IDE-Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Mar 22, 2024
1 parent 4c5ebf6 commit 726fe09
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* </ul>
* <p>
* The only thing the child-component needs to care is implementing
* {@link #getComponentSpecificStyleClasses()} according to its needs.
* {@link #resolveComponentSpecificStyleClasses()} according to its needs.
* </p>
*
* @author Oliver Wolff
Expand Down Expand Up @@ -81,7 +81,7 @@ public UIComponent facet(final String facetName) {

@Override
public String getStyleClass() {
return getComponentSpecificStyleClasses().append(styleClassProvider.getStyleClassBuilder()).getStyleClass();
return resolveComponentSpecificStyleClasses().append(styleClassProvider.getStyleClassBuilder()).getStyleClass();
}

@Override
Expand All @@ -98,7 +98,7 @@ public void setStyleClass(final String styleClass) {
* appending the styleClass configured by the developer / concrete
* usage.
*/
public abstract StyleClassBuilder getComponentSpecificStyleClasses();
public abstract StyleClassBuilder resolveComponentSpecificStyleClasses();

@Override
public String getTitle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,26 @@
* Defines the relative float-alignments.
*
* @author Oliver Wolff
*
*/
@Getter
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public enum AlignHolder implements StyleClassProvider {

/** Left-align */
/**
* Left-align
*/
LEFT(CssCommon.PULL_LEFT.getStyleClass()),

/** Right-align */
/**
* Right-align
*/
RIGHT(CssCommon.PULL_RIGHT.getStyleClass()),

/** Not defined. */
/**
* Not defined.
*/
DEFAULT("");

@Getter
private final String styleClass;

@Override
Expand All @@ -51,27 +56,25 @@ public StyleClassBuilder getStyleClassBuilder() {
/**
* Create an instance of {@link AlignHolder} according to the given String.
*
* @param align String identifier, may be null. The call is case insensitive.
* "right" will result in {@link AlignHolder#LEFT}, "right" in
* {@link AlignHolder#RIGHT}. In all other cases it will return
* {@link AlignHolder#DEFAULT}
* @param align String identifier may be null.
* The call is case-insensitive.
* "right" will result in {@link AlignHolder#RIGHT}, "left" in
* {@link AlignHolder#LEFT}.
* In all other cases it will return {@link AlignHolder#DEFAULT}
* @return the corresponding {@link AlignHolder}
*/
public static final AlignHolder getFromString(String align) {
var result = AlignHolder.DEFAULT;
public static AlignHolder getFromString(String align) {
if (!isEmpty(align)) {
var upperCase = align.toUpperCase();
switch (upperCase) {
case "LEFT":
result = LEFT;
break;
case "RIGHT":
result = RIGHT;
break;
default:
break;
case "LEFT":
return LEFT;
case "RIGHT":
return RIGHT;
default:
break;
}
}
return result;
return AlignHolder.DEFAULT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,61 @@
* Represents the bootstrap context-state.
*
* @author Oliver Wolff
*
*/
public enum ContextSize {

/** The default size. Will usually ignored. */
/**
* The default size. Will usually ignored.
*/
DEFAULT,
/** Extras Small. */
/**
* Extras Small.
*/
XS,
/** Small. */
/**
* Small.
*/
SM,
/** Medium. */
/**
* Medium.
*/
MD,
/** Large. */
/**
* Large.
*/
LG,
/** XL, addition to bootstrap. */
/**
* XL, addition to bootstrap.
*/
XL,
/** XXL, addition to bootstrap. */
/**
* XXL, addition to bootstrap.
*/
XXL,
/** XXXL, addition to bootstrap. */
/**
* XXXL, addition to bootstrap.
*/
XXXL;

/**
* Factory method for computing an {@link ContextSize} out of a given
* {@link String}
*
* @param size String representation of the size. It is interpreted case
* insensitive. It can be either null or empty or must be one of
* {"XS", "SM", "MD", "LG", "XL", "XXL", "XXXL"} (case insensitive).
* @param size String representation of the size.
* It is interpreted case-insensitive.
* It can be either null or empty or must be one of
* {"XS", "SM", "MD", "LG", "XL", "XXL", "XXXL"} (case-insensitive).
* The Input will implicitly be trimmed.
* @return The {@link ContextSize} representation computed of the given String.
* If it is null or empty {@link ContextSize#DEFAULT} will be returned.
* If the given String does not match to the constants a
* {@link IllegalArgumentException} will be thrown.
* If it is null or empty {@link ContextSize#DEFAULT} will be returned.
* If the given String does not match to the constants a
* {@link IllegalArgumentException} will be thrown.
*/
public static final ContextSize getFromString(String size) {
var result = DEFAULT;
public static ContextSize getFromString(String size) {
if (!MoreStrings.isBlank(size)) {
result = valueOf(size.trim().toUpperCase());
return valueOf(size.trim().toUpperCase());
}
return result;
return DEFAULT;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,56 @@
*/
public enum ContextState implements StyleClassProvider {

/** The default state. Will usually ignored. */
/**
* The default state. Will usually ignored.
*/
DEFAULT,
/** Primary. */
/**
* Primary.
*/
PRIMARY,
/** Success. */
/**
* Success.
*/
SUCCESS,
/** Info. */
/**
* Info.
*/
INFO,
/** warning. */
/**
* warning.
*/
WARNING,
/** A more visual state. */
/**
* A more visual state.
*/
LIGHT,
/** Danger. */
/**
* Danger.
*/
DANGER;

/**
* Factory method for computing an {@link ContextState} out of a given
* {@link String}
*
* @param state String representation of the state. It is interpreted case
* insensitive. It can be either null or empty or must be one of
* @param state String representation of the state.
* It is interpreted case-insensitive.
* It can be either null or empty or must be one of
* {"DEFAULT","PRIMARY", "SUCCESS", "INFO", "WARNING", "DANGER",
* "LIGHT"} (case insensitive). The Input will implicitly be
* "LIGHT"} (case-insensitive).
* The Input will implicitly be
* trimmed.
* @return The {@link ContextState} representation computed of the given String.
* If it is null or empty {@link ContextState#DEFAULT} will be returned.
* If the given String does not match to the constants a
* {@link IllegalArgumentException} will be thrown.
* If it is null or empty {@link ContextState#DEFAULT} will be returned.
* If the given String does not match to the constants a
* {@link IllegalArgumentException} will be thrown.
*/
public static final ContextState getFromString(final String state) {
var result = DEFAULT;
public static ContextState getFromString(final String state) {
if (!MoreStrings.isBlank(state)) {
result = valueOf(state.trim().toUpperCase());
return valueOf(state.trim().toUpperCase());
}
return result;
return DEFAULT;
}

/**
Expand All @@ -73,7 +88,7 @@ public final String getStyleClassWithPrefix(final String prefix) {
if (MoreStrings.isEmpty(prefix)) {
return getStyleClass();
}
return new StringBuilder().append(prefix).append('-').append(name().toLowerCase()).toString();
return prefix + '-' + name().toLowerCase();
}

/**
Expand All @@ -96,7 +111,7 @@ public final String getStyleClass() {

/**
* @return StyleClassBuilder with the current ContextState in lower case as base
* class.
* class.
*/
@Override
public StyleClassBuilder getStyleClassBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @author Oliver Wolff
*
*/
@Getter
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public enum CssCommon implements StyleClassProvider {

Expand All @@ -37,7 +38,6 @@ public enum CssCommon implements StyleClassProvider {
/** Shorthand for Bootstrap-style float:left. */
PULL_LEFT("pull-left");

@Getter
private final String styleClass;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@
import lombok.RequiredArgsConstructor;

/**
* Models the supported IconLibraries. This is necessary, because icons are
* usually referenced as two classes, e.g. "cui-icon cui-icon-warning". This
* separation is because css performance, but complicates the usage.
* Models the supported IconLibraries.
* This is necessary because icons are
* usually referenced as two classes, e.g. "cui-icon cui-icon-warning".
* This separation is because of css performance, but complicates the usage.
* <p>
* In order to work this class returns the corresponding base class, e.g if the
* provided class is "cui-icon-warning" it returns "cui-icon".
* </p>
* <p>
* In order to prevent improper usage the matching is restricted to the
* prefixes: "cui-icon, cui-mime-type, ui-icon-". If none of them is matched the
* In order to prevent improper usage, the matching is restricted to the
* prefixes: "cui-icon, cui-mime-type, ui-icon-".
* If none of them is matched the
* access throws an {@link IllegalArgumentException}.
*
* @author Oliver Wolff (Oliver Wolff)
*/
@Getter
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public enum IconLibrary {

Expand All @@ -54,19 +57,18 @@ public enum IconLibrary {
*/
JQUERY_UI("ui-icon");

@Getter
private final String libraryPrefix;

/**
* Strips and matches the corresponding library name.
*
* @param iconClass must not be null
* @return the resolved library, if there is a match, otherwise it throws an
* {@link IllegalArgumentException}
* {@link IllegalArgumentException}
* @throws IllegalArgumentException if iconClass is {@code null} or
* {@code empty}.
*/
public static final String resolveLibraryFromIconClass(String iconClass) {
public static String resolveLibraryFromIconClass(String iconClass) {

final var checked = requireNotEmpty(iconClass, "iconClass");

Expand All @@ -80,14 +82,14 @@ public static final String resolveLibraryFromIconClass(String iconClass) {

/**
* Strip the corresponding library class and creates the combined css String,
* e.g. "pxs-icon pxs-icon-warning" for for iconClass=pxs-icon-warning.
* e.g. "pxs-icon pxs-icon-warning" for iconClass=pxs-icon-warning.
*
* @param iconClass must not be null
* @return the computed css String.
*/
public static final String resolveCssString(String iconClass) {
public static String resolveCssString(String iconClass) {
var libraryName = resolveLibraryFromIconClass(iconClass);
return new StringBuilder(libraryName).append(' ').append(iconClass).toString();
return libraryName + ' ' + iconClass;
}

/**
Expand All @@ -96,7 +98,7 @@ public static final String resolveCssString(String iconClass) {
* @param iconName target which should be verified. Must not be {@code null} or
* {@code empty}.
* @return {@code true} if icon name belongs to known namespaces, {@code false}
* otherwise
* otherwise
* @throws IllegalArgumentException if iconName is {@code null} or
* {@code empty}.
*/
Expand Down
Loading

0 comments on commit 726fe09

Please sign in to comment.