From 5395541126aa84bf8c0cadac2dfccd14855951b7 Mon Sep 17 00:00:00 2001 From: Andy Seaborne Date: Sat, 3 Feb 2024 15:44:55 +0000 Subject: [PATCH] Use lambdas in lang/ParserSPARQL_N --- .../jena/sparql/lang/ParserSPARQL10.java | 27 ++++++------------- .../jena/sparql/lang/ParserSPARQL11.java | 26 +++++------------- .../jena/sparql/lang/ParserSPARQL12.java | 27 +++++-------------- 3 files changed, 22 insertions(+), 58 deletions(-) diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL10.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL10.java index 3c74b52687e..1474ca47772 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL10.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL10.java @@ -39,25 +39,17 @@ private interface Action { void exec(SPARQLParser10 parser) throws Exception ; } protected Query parse$(final Query query, String queryString) { query.setSyntax(Syntax.syntaxSPARQL_10); - Action action = new Action() { - @Override - public void exec(SPARQLParser10 parser) throws Exception { - parser.QueryUnit(); - } - }; - + Action action = (SPARQLParser10 parser) -> + parser.QueryUnit(); perform(query, queryString, action); return query; } public static Element parseElement(String string) { final Query query = new Query(); - Action action = new Action() { - @Override - public void exec(SPARQLParser10 parser) throws Exception { - Element el = parser.GroupGraphPattern(); - query.setQueryPattern(el); - } + Action action = (SPARQLParser10 parser) ->{ + Element el = parser.GroupGraphPattern(); + query.setQueryPattern(el); }; perform(query, string, action); return query.getQueryPattern(); @@ -65,12 +57,9 @@ public void exec(SPARQLParser10 parser) throws Exception { public static Template parseTemplate(String string) { final Query query = new Query(); - Action action = new Action() { - @Override - public void exec(SPARQLParser10 parser) throws Exception { - Template t = parser.ConstructTemplate(); - query.setConstructTemplate(t); - } + Action action = (SPARQLParser10 parser) ->{ + Template t = parser.ConstructTemplate(); + query.setConstructTemplate(t); }; perform(query, string, action); return query.getConstructTemplate(); diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL11.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL11.java index 732b5ef272a..f40b04f0094 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL11.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL11.java @@ -39,25 +39,16 @@ private interface Action { void exec(SPARQLParser11 parser) throws Exception ; } protected Query parse$(final Query query, String queryString) { query.setSyntax(Syntax.syntaxSPARQL_11); - Action action = new Action() { - @Override - public void exec(SPARQLParser11 parser) throws Exception { - parser.QueryUnit(); - } - }; - + Action action = (SPARQLParser11 parser) -> parser.QueryUnit(); perform(query, queryString, action); return query; } public static Element parseElement(String string) { final Query query = new Query(); - Action action = new Action() { - @Override - public void exec(SPARQLParser11 parser) throws Exception { - Element el = parser.GroupGraphPattern(); - query.setQueryPattern(el); - } + Action action = (SPARQLParser11 parser) -> { + Element el = parser.GroupGraphPattern(); + query.setQueryPattern(el); }; perform(query, string, action); return query.getQueryPattern(); @@ -65,12 +56,9 @@ public void exec(SPARQLParser11 parser) throws Exception { public static Template parseTemplate(String string) { final Query query = new Query(); - Action action = new Action() { - @Override - public void exec(SPARQLParser11 parser) throws Exception { - Template t = parser.ConstructTemplate(); - query.setConstructTemplate(t); - } + Action action = (SPARQLParser11 parser) -> { + Template t = parser.ConstructTemplate(); + query.setConstructTemplate(t); }; perform(query, string, action); return query.getConstructTemplate(); diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL12.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL12.java index e097c203128..a2baddb7246 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL12.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/lang/ParserSPARQL12.java @@ -38,26 +38,16 @@ private interface Action { void exec(SPARQLParser12 parser) throws Exception ; } @Override protected Query parse$(final Query query, String queryString) { query.setSyntax(Syntax.syntaxSPARQL_12); - - Action action = new Action() { - @Override - public void exec(SPARQLParser12 parser) throws Exception { - parser.QueryUnit(); - } - }; - + Action action = (SPARQLParser12 parser) -> parser.QueryUnit(); perform(query, queryString, action); return query; } public static Element parseElement(String string) { final Query query = new Query(); - Action action = new Action() { - @Override - public void exec(SPARQLParser12 parser) throws Exception { - Element el = parser.GroupGraphPattern(); - query.setQueryPattern(el); - } + Action action = (SPARQLParser12 parser) -> { + Element el = parser.GroupGraphPattern(); + query.setQueryPattern(el); }; perform(query, string, action); return query.getQueryPattern(); @@ -65,12 +55,9 @@ public void exec(SPARQLParser12 parser) throws Exception { public static Template parseTemplate(String string) { final Query query = new Query(); - Action action = new Action() { - @Override - public void exec(SPARQLParser12 parser) throws Exception { - Template t = parser.ConstructTemplate(); - query.setConstructTemplate(t); - } + Action action = (SPARQLParser12 parser) -> { + Template t = parser.ConstructTemplate(); + query.setConstructTemplate(t); }; perform(query, string, action); return query.getConstructTemplate();