Skip to content

Commit

Permalink
fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed May 11, 2024
1 parent fdc3e5b commit 90d13e5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main/java/org/omnifaces/converter/GenericEnumConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.omnifaces.util.Faces.getViewAttribute;
import static org.omnifaces.util.Faces.setViewAttribute;
import static org.omnifaces.util.Messages.createError;
import static org.omnifaces.util.Utils.coalesce;
import static org.omnifaces.util.Utils.isOneOf;

import java.lang.reflect.Method;
Expand Down Expand Up @@ -87,8 +86,9 @@ public class GenericEnumConverter implements Converter {
// Constants ------------------------------------------------------------------------------------------------------

private static final String ATTRIBUTE_ENUM_TYPE = "GenericEnumConverter.%s";
private static final String ERROR_NO_ENUM_TYPE = "Given type ''{0}'' is not an enum.";
private static final String ERROR_NO_ENUM_INSTANCE = "Given type ''{0}'' is not an enum.";
private static final String ERROR_NO_ENUM_VALUE = "Given value ''{0}'' is not an enum of type ''{1}''.";
private static final String ERROR_NO_ENUM_TYPE = "Cannot determine enum type, use standard EnumConverter instead.";

// Actions --------------------------------------------------------------------------------------------------------

Expand All @@ -106,7 +106,7 @@ public String getAsString(FacesContext context, UIComponent component, Object mo
return ((Enum) modelValue).name();
}
else {
throw new ConverterException(createError(ERROR_NO_ENUM_TYPE, modelValue.getClass()));
throw new ConverterException(createError(ERROR_NO_ENUM_INSTANCE, modelValue.getClass()));
}
}

Expand All @@ -117,10 +117,11 @@ public Object getAsObject(FacesContext context, UIComponent component, String su
return null;
}

Class<Enum> enumType = coalesce(
getAttribute(component, ATTRIBUTE_ENUM_TYPE),
getViewAttribute(format(ATTRIBUTE_ENUM_TYPE, component.getClientId(context)))
);
Class<Enum> enumType = getAttribute(component, ATTRIBUTE_ENUM_TYPE);

if (enumType == null) {
getViewAttribute(format(ATTRIBUTE_ENUM_TYPE, component.getClientId(context)));
}

if (enumType == null) {
try {
Expand Down

0 comments on commit 90d13e5

Please sign in to comment.