PropertyCreationHelper { public static <T> Property<T> createFromName(@NotNull final Optional<String> getSetMethodName) { return createFromName(getSetMethodName.map(name -> "get" + name), getSetMethodName.map(name -> "set" + name)); } private  PropertyCreationHelper(); static Property<T> createFromStaticValue(@Nullable T value); static Property<T> createFromOptional(
      @Nullable final Function<Object, T> getter,
      @Nullable final BiConsumer<Object, T> setter,
      @NotNull final boolean requiresDataContext); static Property<T> create(
      @NotNull final Optional<Function<Object, T>> getter,
      @NotNull final Optional<BiConsumer<Object, T>> setter,
      @NotNull final boolean requiresDataContext); static Property<T> createFromNonOptional(
      @NotNull final Function<Object, T> getter,
      @NotNull final BiConsumer<Object, T> setter,
      @NotNull final boolean requiresDataContext); static Property<T> createFromName(@NotNull final Optional<String> getSetMethodName); @SuppressWarnings({"OptionalUsedAsFieldOrParameterType", "unchecked"}) static Property<T> createFromName(
      @NotNull final Optional<String> getMethodName,
      @NotNull final Optional<String> setMethodName);  }
@Test public void createFromName1() { final DummyTestTarget testTarget = new DummyTestTarget(); final Property<String> bothSet = PropertyCreationHelper.createFromName(Optional.of("getValueOne"), Optional.of("setValueTwo")); Assert.assertFalse(bothSet instanceof StaticValueProperty); Assert.assertEquals("One", bothSet.apply(testTarget).get()); bothSet.accept(testTarget, "Set"); Assert.assertEquals("Set", testTarget.getValueTwo()); Assert.assertEquals("One", testTarget.getValueOne()); }
@Test public void createFromName() { final DummyTestTarget testTarget = new DummyTestTarget(); final Property<String> bothSet = PropertyCreationHelper.createFromName(Optional.of("ValueOne")); Assert.assertFalse(bothSet instanceof StaticValueProperty); Assert.assertEquals("One", bothSet.apply(testTarget).get()); bothSet.accept(testTarget, "Set"); Assert.assertEquals("Set", testTarget.getValueOne()); }