SymbolLookup { @Nonnull public static Set<String> getSymbolValue(@Nonnull Object o) { if (o instanceof Describable) { return getSymbolValue(((Describable) o).getDescriptor().getClass()); } else { return getSymbolValue(o.getClass()); } }  T find(Class<T> type, String symbol); Descriptor<?> findDescriptor(Class<?> type, String symbol); static SymbolLookup get(); @Nonnull static Set<String> getSymbolValue(@Nonnull Object o); @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Jenkins.getInstance() can return null in theory.") @Nonnull static Set<String> getSymbolValue(@Nonnull Class<?> c);  }
@Test public void symbolValueFromObject() { Set<String> netSet = Collections.singleton("net"); Set<String> fooSet = Collections.singleton("foo"); assertEquals(Collections.emptySet(), SymbolLookup.getSymbolValue("some-string")); FishingNet fishingNet = new FishingNet(); assertEquals(netSet, SymbolLookup.getSymbolValue(fishingNet)); assertEquals(netSet, SymbolLookup.getSymbolValue(fishingNetDescriptor)); assertEquals(fooSet, SymbolLookup.getSymbolValue(foo)); }
@Test public void symbolValueFromClass() { Set<String> netSet = Collections.singleton("net"); Set<String> fooSet = Collections.singleton("foo"); assertEquals(Collections.emptySet(), SymbolLookup.getSymbolValue(String.class)); assertEquals(netSet, SymbolLookup.getSymbolValue(FishingNet.class)); assertEquals(netSet, SymbolLookup.getSymbolValue(FishingNet.DescriptorImpl.class)); assertEquals(fooSet, SymbolLookup.getSymbolValue(Foo.class)); }
@Issue("JENKINS-26093") @Test public void parameters() { assertEquals(Collections.singleton("booleanParam"), SymbolLookup.getSymbolValue(BooleanParameterValue.class)); assertEquals(Collections.singleton("booleanParam"), SymbolLookup.getSymbolValue(new BooleanParameterValue("flag", true))); }
@Issue("JENKINS-37820") @Test public void descriptorIsDescribable() { assertEquals(Collections.singleton("whatever"), SymbolLookup.getSymbolValue(SomeConfiguration.class)); assertEquals(Collections.singleton("whatever"), SymbolLookup.getSymbolValue(rule.jenkins.getDescriptorByType(SomeConfiguration.class))); }