Skip to content

Commit f596fa0

Browse files
authored
add inferred return type to IWithKeywordParameters::getParameter to avoid a lot of casting in client code. This should be source-backward compatible, not binary though (#310)
1 parent b12b40b commit f596fa0

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/io/usethesource/vallang/IWithKeywordParameters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface IWithKeywordParameters<T extends IValue> {
2525
* @param label identifies the parameter
2626
* @return a value if the parameter has a value on this node or null otherwise
2727
*/
28-
public @Nullable IValue getParameter(String label);
28+
public <X extends IValue> @Nullable X getParameter(String label);
2929

3030
/**
3131
* Set the value of an parameter

src/main/java/io/usethesource/vallang/impl/fields/AbstractDefaultWithKeywordParameters.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ public String toString() {
6565
return content.toString();
6666
}
6767

68+
@SuppressWarnings("unchecked")
6869
@Override
69-
public @Nullable IValue getParameter(String label) {
70-
return parameters.get(label);
70+
public @Nullable <X extends IValue> X getParameter(String label) {
71+
return (X) parameters.get(label);
7172
}
7273

7374
@Override

0 commit comments

Comments
 (0)