Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FacesMessage optimizations #5260

Merged
merged 3 commits into from
Jul 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions impl/src/main/java/jakarta/faces/application/FacesMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@

package jakarta.faces.application;

import static java.util.Arrays.stream;
import static java.util.Collections.unmodifiableMap;
import static java.util.stream.Collectors.toMap;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
* <p>
Expand Down Expand Up @@ -71,6 +73,8 @@ public class FacesMessage implements Serializable {

// --------------------------------------------------------------- Constants

private static final long serialVersionUID = -1180773928220076822L;

/**
* <p>
* <code>ResourceBundle</code> identifier for messages whose message identifiers are defined in the Jakarta Faces
Expand Down Expand Up @@ -135,22 +139,12 @@ public class FacesMessage implements Serializable {
*/
public static final List VALUES = List.of(values);

private static final Map<String, Severity> _MODIFIABLE_MAP = new HashMap<>(4, 1.0f);

static {
for (Severity value : values) {
_MODIFIABLE_MAP.put(value.severityName, value);
}
}

/**
* <p>
* Immutable <code>Map</code> of valid {@link jakarta.faces.application.FacesMessage.Severity} instances, keyed by name.
* </p>
*/
public final static Map VALUES_MAP = unmodifiableMap(_MODIFIABLE_MAP);

private static final long serialVersionUID = -1180773928220076822L;
public final static Map VALUES_MAP = unmodifiableMap(stream(values).collect(toMap(severity -> severity.severityName , Function.identity())));

// ------------------------------------------------------ Instance Variables

Expand Down