Skip to content

Commit 74f8d30

Browse files
committed
[ignore] code cleanup
1 parent be7cb57 commit 74f8d30

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/org/exist/xquery/functions/map/MapExpr.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,22 @@
1515
*/
1616
public class MapExpr extends AbstractExpression {
1717

18-
protected List<Mapping> mappings = new ArrayList(13);
18+
private final List<Mapping> mappings = new ArrayList<>(13);
1919

20-
public MapExpr(XQueryContext context) {
20+
public MapExpr(final XQueryContext context) {
2121
super(context);
2222
}
2323

24-
public void map(PathExpr key, PathExpr value) {
24+
public void map(final PathExpr key, final PathExpr value) {
2525
final Mapping mapping = new Mapping(key.simplify(), value.simplify());
2626
this.mappings.add(mapping);
2727
}
2828

29-
public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
30-
if(getContext().getXQueryVersion() < 30){
29+
@Override
30+
public void analyze(final AnalyzeContextInfo contextInfo) throws XPathException {
31+
if (getContext().getXQueryVersion() < 30) {
3132
throw new XPathException(this, ErrorCodes.EXXQDY0003,
32-
"Map is not available before XQuery 3.0");
33+
"Map is not available before XQuery 3.0");
3334
}
3435
contextInfo.setParent(this);
3536
for (final Mapping mapping : this.mappings) {
@@ -38,35 +39,40 @@ public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
3839
}
3940
}
4041

41-
public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {
42-
if (contextItem != null)
43-
{contextSequence = contextItem.toSequence();}
42+
@Override
43+
public Sequence eval(Sequence contextSequence, final Item contextItem) throws XPathException {
44+
if (contextItem != null) {
45+
contextSequence = contextItem.toSequence();
46+
}
4447
final MapType map = new MapType(this.context);
4548
for (final Mapping mapping : this.mappings) {
4649
final Sequence key = mapping.key.eval(contextSequence);
47-
if (key.getItemCount() != 1)
48-
{throw new XPathException(MapErrorCode.EXMPDY001, "Expected single value for key, got " + key.getItemCount());}
50+
if (key.getItemCount() != 1) {
51+
throw new XPathException(MapErrorCode.EXMPDY001, "Expected single value for key, got " + key.getItemCount());
52+
}
4953
final AtomicValue atomic = key.itemAt(0).atomize();
5054
final Sequence value = mapping.value.eval(contextSequence);
5155
map.add(atomic, value);
5256
}
5357
return map;
5458
}
5559

60+
@Override
5661
public int returnsType() {
5762
return Type.MAP;
5863
}
5964

6065
@Override
61-
public void accept(ExpressionVisitor visitor) {
66+
public void accept(final ExpressionVisitor visitor) {
6267
super.accept(visitor);
63-
for (final Mapping mapping: this.mappings) {
68+
for (final Mapping mapping : this.mappings) {
6469
mapping.key.accept(visitor);
6570
mapping.value.accept(visitor);
6671
}
6772
}
6873

69-
public void dump(ExpressionDumper dumper) {
74+
@Override
75+
public void dump(final ExpressionDumper dumper) {
7076
dumper.display("map {");
7177
for (final Mapping mapping : this.mappings) {
7278
mapping.key.dump(dumper);
@@ -77,7 +83,7 @@ public void dump(ExpressionDumper dumper) {
7783
}
7884

7985
@Override
80-
public void resetState(boolean postOptimization) {
86+
public void resetState(final boolean postOptimization) {
8187
super.resetState(postOptimization);
8288
mappings.forEach(m -> m.resetState(postOptimization));
8389
}
@@ -86,12 +92,12 @@ private static class Mapping {
8692
final Expression key;
8793
final Expression value;
8894

89-
public Mapping(Expression key, Expression value) {
95+
public Mapping(final Expression key, final Expression value) {
9096
this.key = key;
9197
this.value = value;
9298
}
9399

94-
private void resetState(boolean postOptimization) {
100+
private void resetState(final boolean postOptimization) {
95101
key.resetState(postOptimization);
96102
value.resetState(postOptimization);
97103
}

0 commit comments

Comments
 (0)