Clarify usage of @GerritConfig#value() and #values()

If the value() is given, it takes precedence over values(), i.e.
values() is ignored if value() is specified.

Add Javadoc and a test to clarify this behavior.

Change-Id: I1bf8bd732f973a8d7106601d54680728ad1e0763
This commit is contained in:
David Pursehouse
2017-06-03 15:24:17 +09:00
parent d2a95d21c0
commit 6e1131c763
2 changed files with 18 additions and 0 deletions

View File

@@ -34,7 +34,13 @@ public @interface GerritConfig {
*/
String name();
/**
* Single value. Takes precedence over values specified in {@code values}.
*/
String value() default "";
/**
* Multiple values (list). Ignored if {@code value} is specified.
*/
String[] values() default "";
}

View File

@@ -66,4 +66,16 @@ public class UseGerritConfigAnnotationTest extends AbstractDaemonTest {
.asList()
.containsExactly("value-1", "value-2");
}
@Test
@GerritConfig(
name = "section.name",
value = "value-1",
values = {"value-2", "value-3"}
)
public void valueHasPrecedenceOverValues() {
assertThat(cfg.getStringList("section", null, "name"))
.asList()
.containsExactly("value-1");
}
}