Skip to content

Commit

Permalink
facelets.compiler classes use strong types
Browse files Browse the repository at this point in the history
Signed-off-by: Emil Sierżęga <emilsierzega@gmail.com>
  • Loading branch information
Emkas committed Jun 24, 2022
1 parent df1fc8c commit 1a7f8c7
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ private Tag trimNSAttributes(Tag tag) {
if (remove == 0) {
return tag;
} else {
List attrList = new ArrayList(attr.length);
List<TagAttribute> attrList = new ArrayList<>(attr.length);
int p = 0;
for (int i = 0; i < attr.length; i++) {
p = 1 << i;
Expand All @@ -475,7 +475,7 @@ private Tag trimNSAttributes(Tag tag) {
}
attrList.add(attr[i]);
}
attr = (TagAttribute[]) attrList.toArray(new TagAttribute[attrList.size()]);
attr = attrList.toArray(new TagAttribute[attrList.size()]);
return new Tag(tag.getLocation(), tag.getNamespace(), tag.getLocalName(), tag.getQName(), new TagAttributesImpl(attr));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String toString() {
}
};

private List children;
private List<CompilationUnit> children;

public CompilationUnit() {
}
Expand All @@ -58,7 +58,7 @@ protected void finishNotify(CompilationManager manager) {

public void addChild(CompilationUnit unit) {
if (children == null) {
children = new ArrayList();
children = new ArrayList<>();
}
children.add(unit);
}
Expand All @@ -76,12 +76,12 @@ protected final FaceletHandler getNextFaceletHandler() {
return LEAF;
}
if (children.size() == 1) {
CompilationUnit u = (CompilationUnit) children.get(0);
CompilationUnit u = children.get(0);
return u.createFaceletHandler();
}
FaceletHandler[] fh = new FaceletHandler[children.size()];
for (int i = 0; i < fh.length; i++) {
fh[i] = ((CompilationUnit) children.get(i)).createFaceletHandler();
fh[i] = children.get(i).createFaceletHandler();
}
return new CompositeFaceletHandler(fh);
}
Expand Down
14 changes: 7 additions & 7 deletions impl/src/main/java/com/sun/faces/facelets/compiler/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public abstract class Compiler {

private boolean trimmingComments = false;

private final List libraries = new ArrayList();
private final List<TagLibrary> libraries = new ArrayList<>();

private final List decorators = new ArrayList();
private final List<TagDecorator> decorators = new ArrayList<>();

private final Map features = new HashMap();
private final Map<String, String> features = new HashMap<>();

/**
*
Expand All @@ -90,7 +90,7 @@ public final FaceletHandler metadataCompile(URL src, String alias) throws IOExce

public final TagDecorator createTagDecorator() {
if (decorators.size() > 0) {
return new CompositeTagDecorator((TagDecorator[]) decorators.toArray(new TagDecorator[decorators.size()]));
return new CompositeTagDecorator(decorators.toArray(new TagDecorator[decorators.size()]));
}
return EMPTY_DECORATOR;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ public final ExpressionFactory createExpressionFactory() {
}

private final Object featureInstance(String name) {
String type = (String) features.get(name);
String type = features.get(name);
if (type != null) {
try {
return ReflectionUtil.forName(type).newInstance();
Expand All @@ -140,7 +140,7 @@ private final Object featureInstance(String name) {

public final TagLibrary createTagLibrary(CompilationMessageHolder unit) {
if (libraries.size() > 0) {
return new CompositeTagLibrary((TagLibrary[]) libraries.toArray(new TagLibrary[libraries.size()]), unit);
return new CompositeTagLibrary(libraries.toArray(new TagLibrary[libraries.size()]), unit);
}
return EMPTY_LIBRARY;
}
Expand All @@ -157,7 +157,7 @@ public final void setFeature(String name, String value) {
}

public final String getFeature(String name) {
return (String) features.get(name);
return features.get(name);
}

public final boolean isTrimmingComments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
final class NamespaceHandler extends FunctionMapper implements FaceletHandler {

private final TagLibrary library;
private final Map ns;
private final Map<String, String> ns;
private FaceletHandler next;

public NamespaceHandler(FaceletHandler next, TagLibrary library, Map ns) {
public NamespaceHandler(FaceletHandler next, TagLibrary library, Map<String, String> ns) {
this.library = library;
this.ns = ns;
this.next = next;
Expand All @@ -57,7 +57,7 @@ public void apply(FaceletContext ctx, UIComponent parent) throws IOException {

@Override
public Method resolveFunction(String prefix, String localName) {
String uri = (String) ns.get(prefix);
String uri = ns.get(prefix);
if (uri != null) {
return library.createFunction(uri, localName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public NS(String prefix, String ns) {
}
}

private final List namespaces;
private final List<NS> namespaces;

/**
*
*/
public NamespaceManager() {
namespaces = new ArrayList();
namespaces = new ArrayList<>();
}

public void reset() {
Expand All @@ -59,7 +59,7 @@ public void pushNamespace(String prefix, String namespace) {
public String getNamespace(String prefix) {
NS ns = null;
for (int i = 0; i < namespaces.size(); i++) {
ns = (NS) namespaces.get(i);
ns = namespaces.get(i);
if (ns.prefix.equals(prefix)) {
return ns.namespace;
}
Expand All @@ -70,7 +70,7 @@ public String getNamespace(String prefix) {
public void popNamespace(String prefix) {
NS ns = null;
for (int i = 0; i < namespaces.size(); i++) {
ns = (NS) namespaces.get(i);
ns = namespaces.get(i);
if (ns.prefix.equals(prefix)) {
namespaces.remove(i);
return;
Expand All @@ -83,7 +83,7 @@ public NamespaceUnit toNamespaceUnit(TagLibrary library) {
if (namespaces.size() > 0) {
NS ns = null;
for (int i = namespaces.size() - 1; i >= 0; i--) {
ns = (NS) namespaces.get(i);
ns = namespaces.get(i);
unit.setNamespace(ns.prefix, ns.namespace);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
final class NamespaceUnit extends CompilationUnit {

private final Map ns = new HashMap();
private final Map<String, String> ns = new HashMap<>();
private final TagLibrary library;

public NamespaceUnit(TagLibrary library) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@

public class UILeaf extends UIComponentBase implements UntargetableComponent {

private final static Map<String, UIComponent> facets = new HashMap<String, UIComponent>(0, 1.0f) {
private final static Map<String, UIComponent> facets = new HashMap<>(0, 1.0f) {

private static final long serialVersionUID = 2063657587950149152L;

@Override
public void putAll(Map map) {
public void putAll(Map<? extends String, ? extends UIComponent> map) {
// do nothing
}

Expand Down

0 comments on commit 1a7f8c7

Please sign in to comment.