-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dynamic (duck) type resolution to Painless static types (#78575)
This change adds dynamic (duck) type resolution to Painless static types using an annotation ( at dynamic_type ) to control which static types are allowed to be dynamically invoked. This annotation does not chain so any sub classes that also require dynamic type resolution must be annotated as well.
- Loading branch information
Showing
11 changed files
with
331 additions
and
43 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...ss/spi/src/main/java/org/elasticsearch/painless/spi/annotation/DynamicTypeAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.painless.spi.annotation; | ||
|
||
public class DynamicTypeAnnotation { | ||
|
||
public static final String NAME = "dynamic_type"; | ||
|
||
public static final DynamicTypeAnnotation INSTANCE = new DynamicTypeAnnotation(); | ||
|
||
private DynamicTypeAnnotation() { | ||
|
||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
.../src/main/java/org/elasticsearch/painless/spi/annotation/DynamicTypeAnnotationParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.painless.spi.annotation; | ||
|
||
import java.util.Map; | ||
|
||
public class DynamicTypeAnnotationParser implements WhitelistAnnotationParser { | ||
|
||
public static final DynamicTypeAnnotationParser INSTANCE = new DynamicTypeAnnotationParser(); | ||
|
||
private DynamicTypeAnnotationParser() {} | ||
|
||
@Override | ||
public Object parse(Map<String, String> arguments) { | ||
if (arguments.isEmpty() == false) { | ||
throw new IllegalArgumentException( | ||
"unexpected parameters for [@" + DynamicTypeAnnotation.NAME + "] annotation, found " + arguments | ||
); | ||
} | ||
|
||
return DynamicTypeAnnotation.INSTANCE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.