Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support static call by 'Call' mechanism #18

Closed
dakusui opened this issue Aug 21, 2018 · 2 comments
Closed

Support static call by 'Call' mechanism #18

dakusui opened this issue Aug 21, 2018 · 2 comments
Assignees

Comments

@dakusui
Copy link
Owner

dakusui commented Aug 21, 2018

Support static call by 'Call' mechanism.

call("toString").andThenCallStatic(Objects.class, "toString", Call.THIS).$()
callStatic(Objects.class, "toString", Call.THIS).andThen("contains", "hello").$()
call("toString").andThen((String s) -> s.contains("hello")).$()
@dakusui dakusui self-assigned this Aug 21, 2018
@dakusui
Copy link
Owner Author

dakusui commented Aug 27, 2018

Following is an example to call static method.

      Function<Object, String> func = call(String.class, "format", "<me=%s, %s>", varargs(THIS, "hello")).$();

      System.out.println(func.toString());
      System.out.println(func.apply("world"));
      Crest.assertThat(
          func,
          allOf(
              Crest.asString("toString").equalTo("@String.format[<me=%s, %s>, Object:varargs[(THIS), hello]]").$(),
              Crest.asString(call("apply", "world").$()).equalTo("<me=world, hello>").$()
          )
      );

@dakusui
Copy link
Owner Author

dakusui commented Aug 27, 2018

Not only that, we are now able to call an instance method not on a target object by following way.

      Function<Object, String> func = callOn("Hello world", "indexOf", THIS).andThen("toString").$();

      System.out.println(func.toString());
      System.out.println(func.apply("world"));
      Crest.assertThat(
          func,
          allOf(
              Crest.asString("toString").equalTo("Hello world@indexOf[(THIS)]->@toString[]").$(),
              Crest.asString(call("apply", "world").$()).equalTo("6").$()
          )
      );

dakusui added a commit that referenced this issue Aug 27, 2018
dakusui added a commit that referenced this issue Aug 27, 2018
* Issue #18: Methods calls not on target objects. (static, etc.)
* Issue #24: Improve Javadoc.
dakusui added a commit that referenced this issue Aug 27, 2018
* Issue #18: Support static call (and more)
* Issue #24: Improve Javadoc.
* Issue #18: Support static call
* [maven-release-plugin] prepare release thincrest-3.3.2
* [maven-release-plugin] prepare for next development iteration
* [maven-release-plugin] rollback the release of thincrest-3.3.2
@dakusui dakusui closed this as completed Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant