Sinobu

kiss

I

Sinobu is not obsolete framework but utility, which can manipulate objects as a extremely-condensed facade.

Instantiation and Management

Usually, the container which manages the object uses “get” method to provide such functionality. However, Sinobu uses #make(Class). This difference of method name indicates the difference of the way for the management of objects, which also greatly affects the default lifestyle (called Scope in other containers).

We do not provides the functionalities related to object lifecycle through Sinobu, because we believe that it is better to use functionalities equipped in Java as much as possible. For example, if you want to receive initialization callback, it is better to use constructor.

Dependency Injection

Sinobu supports Constructor Injection only. The Constructor Injection is a dependency injection variant where an object gets all its dependencies via the constructor. We can say that there is no possibility that Operation Injection, Field Injection and Interface Injection will be supported in the days to come. This is one of the most important policy in Sinobu. The following is a benefit of Constructor Injection:

  • It makes a strong dependency contract
  • It makes effective use of constructor in object lifecycle
  • It makes JavaBeans property clean
  • It makes testing easy, since dependencies can be passed in as Mock Object

The following is a deficit of Constructor Injection:

  • It can't resolve circular dependency

JobsScheduler

The parallel task scheduler.

NoOPWiseRunnable

No Operation

LangVariableString

The default language in this VM environment.

LoggerWiseTriConsumerString, Level, Object

The user-defined extra log appender.

accept(Aa)boolean

A
Aa
boolean

Always true.

Accept any value. Use with method reference.

void accept() {
    Predicate<String> accept = I::accept;
    assert accept.test("accept") == true;
    assert accept.test("all") == true;
    assert accept.test(null) == true;
}

accept(Aa, Bb)boolean

A
B
Aa
Bb
boolean

Always true.

Accept any value. Use with method reference.

void accept2() {
    BiPredicate<String, Integer> accept = I::accept;
    assert accept.test("accept", 1) == true;
    assert accept.test("all", -1) == true;
    assert accept.test(null, 0) == true;
}

array(Tone, Tother)T

T

Array element types.

Tone

Array to be concatenated at the top.

Tother

Array to be concatenated at the end.

T

Newly created array with concatenated elements.

Creates a new array whose elements are the concatenated elements of the two given arrays.

void concatTwoArrays() {
    String[] head = {"a", "b", "c"};
    String[] tail = {"d", "e"};

    assert Arrays.equals(I.array(head, tail), new String[] {"a", "b", "c", "d", "e"});
}

bundle(Titems)T

T

Interface type.

Titems

A set of objects that implement a common interface.

T

A bundled interface.

Create a new bundled implementation of the interface common to the given objects. Calling a method of the retrieved implementation object will transparently call the same method on all the given objects. In the case of a method with a return value, the result of the last object's call will be used.

In situations where the compiler cannot estimate the type of the common interface, use I#bundle(Class, Object...) instead, which can specify the type.

void bundleRunnables() {
    int[] value = {0};

    Runnable bundled = I.bundle(() -> value[0] += 1, () -> value[0] += 2);
    bundled.run();
    assert value[0] == 3;

    bundled.run();
    assert value[0] == 6;
}
void returnLastInterfaceResult() {
    Function<Integer, Integer> bundled = I.bundle(x -> x + 1, y -> y + 2);
    assert bundled.apply(10) == 12;
}
void cantInferCommonInterface() {
    ArrayList array = new ArrayList();
    LinkedList linked = new LinkedList();

    assertThrows(IllegalArgumentException.class, () -> I.bundle(array, linked));
}

bundle(ClassTtype, Titems)T

T

Interface type.

ClassTtype

Specify the common interfaces.

Titems

A set of objects that implement a common interface.

T

A bundled interface.

Create a new bundled implementation of the interface common to the given objects. Calling a method of the retrieved implementation object will transparently call the same method on all the given objects. In the case of a method with a return value, the result of the last object's call will be used.

void bundleList() {
    ArrayList array = new ArrayList();
    LinkedList linked = new LinkedList();

    List bundled = I.bundle(List.class, array, linked);
    bundled.add(10);

    assert array.size() == 1;
    assert linked.size() == 1;
}

collect(ClassTtype, Vitems)T

TCollectionV

Specify the concrete class which implements the Collection, but the List and Set interfaces may be specified as exceptions.

V

The type of the Collection's items.

ClassTtype

A Collection type.

Vitems

A list of items.

T

The new created Collection.

Create a new Collection to hold the specified items. Basically, the type of the collection should be a real class, but if it is a List or Set, the default implementation class (ArrayList , HashSet) will be used.

public void collect() {
    List<Integer> list = I.collect(List.class, 1, 2, 3);
    assert list instanceof ArrayList;
    assert list.size() == 3;
    assert list.get(0) == 1;
    assert list.get(1) == 2;
    assert list.get(2) == 3;
}
public void collectWithNoItem() {
    List<Integer> list = I.collect(LinkedList.class);
    assert list instanceof LinkedList;
    assert list.isEmpty();
}

copy(InputStreaminput, OutputStreamoutput, booleanclose)void

InputStreaminput InputStream to which data will be read from.
OutputStreamoutput OutputStream to which data will be written to.
booleanclose

Whether input and output streams will be closed automatically or not.

Copies data from InputStream to OutputStream. This method does the data buffering internally, so you do not need to do the buffering explicitly.

void copyInputStream() {
    byte[] bytes = {0, 1, 2, 3};
    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    I.copy(in, out, true);

    assert Arrays.equals(bytes, out.toByteArray());
}

copy(Readableinput, Appendableoutput, booleanclose)void

Readableinput Readable to which data will be read from.
Appendableoutput Appendable to which data will be written to.
booleanclose

Whether input and output streams will be closed automatically or not.

Copies data from Readable to Appendable. This method does the data buffering internally, so you do not need to do the buffering explicitly.

void copyReadable() {
    String value = "test";
    StringReader in = new StringReader(value);
    StringWriter out = new StringWriter();

    I.copy(in, out, true);

    assert out.toString().equals(value);
}

debug(Objectmsg)void

Objectmsg

A message log.

Write java.lang.System.Logger.Level#DEBUG log.

debug(Stringname, Objectmsg)void

Stringname

A logger name.

Objectmsg

A message log.

Write java.lang.System.Logger.Level#DEBUG log.

debug(WiseSuppliermsg)void

WiseSuppliermsg

A message log.

Write java.lang.System.Logger.Level#DEBUG log.

debug(Stringname, WiseSuppliermsg)void

Stringname

A logger name.

WiseSuppliermsg

A message log.

Write java.lang.System.Logger.Level#DEBUG log.

env(Stringname)String

Stringname

A environment variable name.

String

The value of the environment variable with the specified name, or null if it does not exist.

Read environment variables based on the following priorities (sources higher in the list take precedence over those located lower).

  1. System#getenv(String)
  2. .env property file in current working directory (optional)
  3. .env property file on the classpath (optional)
@EnabledIfEnvironmentVariable(named = "TEMP", matches = ".*")
void env() {
    assert I.env("TEMP") != null; // The value varies depending on the execution environment.
    assert I.env("not-exist") == null;
}

env(Stringname, Tdefaults)T

T
Stringname

A environment variable name.

Tdefaults

If the specified name is not found, set and return this default value.

T

The value of the environment variable with the specified name.

Read environment variables based on the following priorities (sources higher in the list take precedence over those located lower). If the environment variable with the specified name does not exist, the value specified as the default value will be set as the new environment variable and used.

  1. System#getenv(String)
  2. .env property file in current working directory (optional)
  3. .env property file on the classpath (optional)

error(Objectmsg)void

Objectmsg

A message log.

Write java.lang.System.Logger.Level#ERROR log.

error(Stringname, Objectmsg)void

Stringname

A logger name.

Objectmsg

A message log.

Write java.lang.System.Logger.Level#ERROR log.

error(WiseSuppliermsg)void

WiseSuppliermsg

A message log.

Write java.lang.System.Logger.Level#ERROR log.

error(Stringname, WiseSuppliermsg)void

Stringname

A logger name.

WiseSuppliermsg

A message log.

Write java.lang.System.Logger.Level#ERROR log.

express(Stringtext, Objectcontexts)String

Stringtext

A text with the path of the property names enclosed in "{}".

Objectcontexts

A list of context values.

String

A calculated text.

It is a very simple template engine that can calculate a string that replaces the path of a property names enclosed in "{}" with the actual value of the property. Support Mustache Syntax partially.

void variable() {
    KVS context = $("lang", "the minimum language");

    assert I.express("I want {lang}.", context).equals("I want the minimum language.");
}
void bean() {
    Person bean = new Person();
    bean.setAge(15);
    bean.setLastName("Kahu");
    bean.setFirstName("Tino");

    assert I.express("{firstName}({age}) : It's noisy.", bean).equals("Tino(15) : It's noisy.");
}
void section() {
    List context = List.of("one", "two", "three");

    assert I.express("""
            <ul>
                {#this}
                <li>{.}</li>
                {/this}
            </ul>
            """, context).equals("""
            <ul>
                <li>one</li>
                <li>two</li>
                <li>three</li>
            </ul>
            """);
}
void sectionByEmptyList() {
    List context = Collections.emptyList();

    assert I.express("{#this}The text here will not be output.{/this}", context).equals("");
}
void sectionByFalse() {
    boolean context = false;

    assert I.express("{#this}The text here will not be output.{/this}", context).equals("");
}
void invertedByEmptyList() {
    List context = Collections.emptyList();

    assert I.express("""
            <ul>
                {#this}
                <li>{.}</li>
                {/this}
                {^this}
                <li>No Items</li>
                {/this}
            </ul>
            """, context).equals("""
            <ul>
                <li>No Items</li>
            </ul>
            """);
}

express(Stringtext, Objectcontexts, WiseTriFunctionModel, Object, String, Objectresolvers)String

Stringtext

A text with the path of the property names enclosed in "{}".

Objectcontexts

A list of context values.

WiseTriFunctionModel, Object, String, Objectresolvers
String

A calculated text.

It is a very simple template engine that can calculate a string that replaces the path of a property names enclosed in "{}" with the actual value of the property. Support Mustache Syntax partially.

express(Stringtext, Stringopen, Stringclose, Objectcontexts, WiseTriFunctionModel, Object, String, Objectresolvers)String

Stringtext

A text with the path of the property names enclosed in "{}".

Stringopen
Stringclose
Objectcontexts

A list of context values.

WiseTriFunctionModel, Object, String, Objectresolvers
String

A calculated text.

It is a very simple template engine that can calculate a string that replaces the path of a property names enclosed in "{}" with the actual value of the property. Support Mustache Syntax partially.

find(ClassEextensionPoint)ListE

EExtensible

An Extension Point.

ClassEextensionPoint

An extension point class. The Extension Point class is only accepted, otherwise this method will return empty list.

ListE

All Extensions of the given Extension Point or empty list.

Find all Extensions which are specified by the given Extension Point.

The returned list will be "safe" in that no references to it are maintained by Sinobu. (In other words, this method must allocate a new list). The caller is thus free to modify the returned list.

find(ClassEextensionPoint, Classkey)E

EExtensible

An Extension Point.

ClassEextensionPoint

An Extension Point class. The Extension Point class is only accepted, otherwise this method will return null.

Classkey

An Extension Key class.

E

An associated Extension of the given Extension Point and the given Extension Key or null.

Find the Extension which are specified by the given Extension Point and the given key.

findAs(ClassEextensionPoint)ListClassE

EExtensible

An Extension Point.

ClassEextensionPoint

An extension point class. The Extension Point class is only accepted, otherwise this method will return empty list.

ListClassE

All Extension classes of the given Extension Point or empty list.

Find all Extensions classes which are specified by the given Extension Point.

The returned list will be "safe" in that no references to it are maintained by Sinobu. (In other words, this method must allocate a new list). The caller is thus free to modify the returned list.

http(Stringrequest, ClassTtype, HttpClientclient)SignalT

T String, InputStream, HttpResponse, XML, or your bean class
Stringrequest

Request URI.

ClassTtype

Response handler. (String, InputStream, HttpResponse, XML, or your bean class)

HttpClientclient
SignalT

If the request is successful, the content will be sent. If the request is unsuccessful, an error will be sent.

Gets the response from the specified URL (including https), converting it to the specified type. Supported types are as follows:

It will check the Content-Encoding header and automatically decompress the body if it is compressed with gzip or deflate. HTTP communication by this method is done asynchronously. It is possible to process it synchronously by calling the return value's Signal#waitForTerminate().

void responseString() {
    httpClientMock.onGet().doReturn("ok");

    assert I.http("http://test.com", String.class, httpClientMock).to().is("ok");
}
void responseHTML() {
    httpClientMock.onGet().doReturnXML("<html><body>contents</body></html>");

    XML xml = I.http("http://test.com", XML.class, httpClientMock).to().exact();
    assert xml.name().equals("html");
    assert xml.text().equals("contents");
}
void responseJSON() {
    httpClientMock.onGet().doReturnJSON(text("{'state' : 'ok'}"));

    JSON json = I.http("http://test.com", JSON.class, httpClientMock).to().exact();
    assert json.get(String.class, "state").equals("ok");
}
void responseMappedType() {
    class Response {
        public String state;
    }

    httpClientMock.onGet().doReturnJSON(text("{'state' : 'ok'}"));

    Response response = I.http("http://test.com", Response.class, httpClientMock).to().exact();
    assert response.state.equals("ok");
}

http(Builderrequest, ClassTtype, HttpClientclient)SignalT

T String, InputStream, HttpResponse, XML, or your bean class
Builderrequest

Request builder.

ClassTtype

Response handler. (String, InputStream, HttpResponse, XML, or your bean class)

HttpClientclient
SignalT

If the request is successful, the content will be sent. If the request is unsuccessful, an error will be sent.

Gets the response from the specified URL (including https), converting it to the specified type. Supported types are as follows:

It will check the Content-Encoding header and automatically decompress the body if it is compressed with gzip or deflate. HTTP communication by this method is done asynchronously. It is possible to process it synchronously by calling the return value's Signal#waitForTerminate().

http(Stringuri, ConsumerWebSocketopen, HttpClientclient)SignalString

Stringuri

URI to connect.

ConsumerWebSocketopen

Called only once, when a connection is established.

HttpClientclient
SignalString

Communication status.

Connect to the specified URI by Websocket. The status of the communication is transmitted to Signal. Once the connection is established, it performs a 'open' callback.

info(Objectmsg)void

Objectmsg

A message log.

Write java.lang.System.Logger.Level#INFO log.

info(Stringname, Objectmsg)void

Stringname

A logger name.

Objectmsg

A message log.

Write java.lang.System.Logger.Level#INFO log.

info(WiseSuppliermsg)void

WiseSuppliermsg

A message log.

Write java.lang.System.Logger.Level#INFO log.

info(Stringname, WiseSuppliermsg)void

Stringname

A logger name.

WiseSuppliermsg

A message log.

Write java.lang.System.Logger.Level#INFO log.

json(Stringinput)JSON

Stringinput

A json format text. null will throw NullPointerException. The empty or invalid format data will throw IllegalStateException.

JSON

A parsed JSON.

Parse the specified JSON format text.

json(Stringinput, ClassTtype)T

T
Stringinput

A json format text. null will throw NullPointerException. The empty or invalid format data will throw IllegalStateException.

ClassTtype
T

A parsed JSON.

Parse the specified JSON format text.

json(Pathinput)JSON

Pathinput

A json format text. null will throw NullPointerException. The empty or invalid format data will throw IllegalStateException.

JSON

A parsed JSON.

Parse the specified JSON format text.

json(InputStreaminput)JSON

InputStreaminput

A json format text. null will throw NullPointerException. The empty or invalid format data will throw IllegalStateException.

JSON

A parsed JSON.

Parse the specified JSON format text.

json(Readerinput)JSON

Readerinput

A json format text. null will throw NullPointerException. The empty or invalid format data will throw IllegalStateException.

JSON

A parsed JSON.

Parse the specified JSON format text.

json(Readerinput, ClassTtype)T

T
Readerinput

A json format text. null will throw NullPointerException. The empty or invalid format data will throw IllegalStateException.

ClassTtype
T

A parsed JSON.

Parse the specified JSON format text.

list(Vitems)ListV

V
Vitems

A list of items.

ListV

The new created ArrayList.

Create ArrayList with the specified items.

load(URLsource)Disposable

URLsource

A source class to indicate the class set which are loaded.

Disposable

Call Disposable#dispose() to unload the registered extension.

Load all Extensible types from the specified source.

You can pass the csv data from "kiss.Extensible" environment variable which enumerates pre-scanned class names.

load(Classsource)Disposable

Classsource

A source class to indicate the class set which are loaded.

Disposable

Call Disposable#dispose() to unload the registered extension.

Load all Extensible types from the specified source.

You can pass the csv data from "kiss.Extensible" environment variable which enumerates pre-scanned class names.

make(Class?TmodelClass)T

T

A model type.

Class?TmodelClass

A target class to create instance.

T

An instance of the specified model class. This instance is managed by Sinobu.

Returns a new or cached instance of the model class.

This method supports the top-level class and the member type. If the local class or the anonymous class is passed to this argument, UnsupportedOperationException will be thrown. There is a possibility that a part of this limitation will be removed in the future.

make(ClassTtype, InvocationHandlerhandler)T

T
ClassTtype

A model type.

InvocationHandlerhandler

A proxy handler.

T

Proxy instance for the given interface.

Create proxy instance.

pair(Aparam1, Bparam2)A, B

A
B
Aparam1

A first parameter.

Bparam2

A second parameter.

A, B

A created tuple.

Create value set.

pair(Aparam1, Bparam2, Cparam3)A, B, C

A
B
C
Aparam1

A first parameter.

Bparam2

A second parameter.

Cparam3

A third parameter.

A, B, C

A created tuple.

Create value set.

prototype(ClassMmodel)LifestyleM

M

A Managed class.

ClassMmodel

A model type.

LifestyleM

A built Lifestyle that creates a new instance every time demanded.

Build prototype-like Lifestyle that creates a new instance every time demanded. This is default lifestyle in Sinobu.

The created Lifestyle has the functionality of Dependency Injection. The Lifestyle attempts to create an instance using the first constructor declared with the fewest number of arguments. If the argument contains a Managed type, an instance of that type will also be created automatically. This dependency injection is done at the same time when the model is instantiated. But if you want to delay the creation of the dependency until it is needed, you can set the argument type to Lifestyle .

You may also specify a Class type as an argument if you need the currently processing model type. This feature is mainly available when implementing the special generic Lifestyle.

prototype(ClassMmodel, WiseFunctionClass, Objectinjector)LifestyleM

M

A Managed class.

P
ClassMmodel

A model type.

WiseFunctionClass, Objectinjector

A injector for parameters. The default injector is I#make(Class).

LifestyleM

A built Lifestyle that creates a new instance every time demanded.

Build prototype-like Lifestyle that creates a new instance every time demanded. This is default lifestyle in Sinobu.

The created Lifestyle has the functionality of Dependency Injection. The Lifestyle attempts to create an instance using the first constructor declared with the fewest number of arguments. If the argument contains a Managed type, an instance of that type will also be created automatically. This dependency injection is done at the same time when the model is instantiated. But if you want to delay the creation of the dependency until it is needed, you can set the argument type to Lifestyle .

You may also specify a Class type as an argument if you need the currently processing model type. This feature is mainly available when implementing the special generic Lifestyle.

quiet(Objectobject)RuntimeException

Objectobject

An exception to throw quietly or an object to close quietly.

RuntimeException

A pseudo unchecked exception.

Close the specified object quietly if it is AutoCloseable. Equivalent to AutoCloseable#close(), except any exceptions will be ignored. This is typically used in finally block like the following.

 AutoCloseable input = null;

 try {
 // some IO action
 } catch (Exception e) {
 throw e;
 } finally {
 I.quiet(input);
 }
 

Throw the specified checked exception quietly or close the specified AutoCloseable object quietly.

This method doesn't wrap checked exception around unchecked exception (e.g. new RuntimeException(e)) and doesn't shelve it. This method deceive the compiler that the checked exception is unchecked one. So you can catch a raw checked exception in the caller of the method which calls this method.

 private void callerWithoutErrorHandling() {
 methodQuietly();
 }

 private void callerWithErrorHandling() {
 try {
 methodQuietly();
 } catch (Exception e) {
 // you can catch the checked exception here
 }
 }

 private void methodQuietly() {
 try {
 // throw some checked exception
 } catch (CheckedException e) {
 throw I.quiet(e); // rethrow checked exception quietly
 }
 }
 

recurse(WiseTriConsumerWiseBiConsumerA, B, A, Bfunction)WiseBiConsumerA, B

A
B
WiseTriConsumerWiseBiConsumerA, B, A, Bfunction

A recursive function.

WiseBiConsumerA, B

A created function.

Define recursive BiConsumer.

 I.recurse((self, param1, param2) -> {
 // your function code
 });
 

recurse(WiseTriFunctionWiseBiFunctionA, B, R, A, B, Rfunction)WiseBiFunctionA, B, R

A
B
R
WiseTriFunctionWiseBiFunctionA, B, R, A, B, Rfunction

A recursive function.

WiseBiFunctionA, B, R

A created function.

Define recursive BiFunction.

 I.recurse((self, param1, param2) -> {
 // your function code
 });
 

recurse(WiseBiConsumerWiseConsumerA, Afunction)WiseConsumerA

A
WiseBiConsumerWiseConsumerA, Afunction

A target function to convert.

WiseConsumerA

A converted recursive function.

Define recursive Consumer.

 I.recurse((self, param) -> {
 // your function code
 });
 

recurse(WiseBiFunctionWiseFunctionA, R, A, Rfunction)WiseFunctionA, R

A
R
WiseBiFunctionWiseFunctionA, R, A, Rfunction

A recursive function.

WiseFunctionA, R

A created function.

Define recursive Function.

 I.recurse((self, param) -> {
 // your function code
 });
 

recurse(WiseConsumerWiseRunnablefunction)WiseRunnable

WiseConsumerWiseRunnablefunction

A recursive function.

WiseRunnable

A created function.

Define recursive Runnable.

 I.recurse(self -> {
 // your function code
 });
 

recurse(WiseFunctionWiseSupplierR, Rfunction)WiseSupplierR

R
WiseFunctionWiseSupplierR, Rfunction

A recursive function.

WiseSupplierR

A created function.

Define recursive Supplier.

 I.recurse(self -> {
 // your function code
 });
 

reject(Aa)boolean

A
Aa
boolean

Always false.

Reject any value. Use with method reference.

void reject() {
    Predicate<String> reject = I::reject;
    assert reject.test("reject") == false;
    assert reject.test("all") == false;
    assert reject.test(null) == false;
}

reject(Aa, Bb)boolean

A
B
Aa
Bb
boolean

Always false.

Reject any value. Use with method reference.

void reject2() {
    BiPredicate<String, Integer> accept = I::reject;
    assert accept.test("reject", 1) == false;
    assert accept.test("all", -1) == false;
    assert accept.test(null, 0) == false;
}

schedule(Runnabletask)CompletableFuture?

Runnabletask

A task to execute.

CompletableFuture?

A result of the executing task.

Execute the specified task in the sinobu managed background thread pool.

schedule(longdelayTime, TimeUnitunit, ScheduledExecutorServicescheduler)SignalLong

longdelayTime

The delay time to wait before emitting the first value of 1L

TimeUnitunit

The time unit for delay time

ScheduledExecutorServicescheduler

The task scheduler.

SignalLong Signal that emits long value (1) after the delay time

Returns an Signal that emits long value (1) after the delay time.

schedule(longdelayTime, longintervalTime, TimeUnitunit, booleanfixedRate, ScheduledExecutorServicescheduler)SignalLong

longdelayTime

The initial delay time to wait before emitting the first value of 1L

longintervalTime

The period of time between emissions of the subsequent numbers

TimeUnitunit

the time unit for both delay time and interval time

booleanfixedRate
ScheduledExecutorServicescheduler
SignalLong Signal that emits long value (1) after the delay time and ever-increasing numbers after each interval time of time thereafter

Returns an Signal that emits long value (1) after the delay time and ever-increasing numbers after each interval time of time thereafter.

schedule(Stringcron)SignalLong

Stringcron

The cron expression.

SignalLong Signal that emits long value (1) at the time and ever-increasing numbers after each interval of time thereafter

Create a time-based periodic executable scheduler. It will be executed at regular intervals starting from a specified base time. For example, if the base time is 00:05 and the interval is 30 minutes, the actual execution time will be 00:05, 00:30, 01:05, 01:35, and so on.

schedule(Stringcron, ZoneIdid)SignalLong

Stringcron

The cron expression.

ZoneIdid
SignalLong Signal that emits long value (1) at the time and ever-increasing numbers after each interval of time thereafter

Create a time-based periodic executable scheduler. It will be executed at regular intervals starting from a specified base time. For example, if the base time is 00:05 and the interval is 30 minutes, the actual execution time will be 00:05, 00:30, 01:05, 01:35, and so on.

set(Vitems)SetV

V
Vitems

A list of items.

SetV

The new created HashSet.

Create HashSet with the specified items.

signal(Vvalues)SignalV

V
Vvalues

A list of values to emit.

SignalV

The Signal to emit sequential values.

Signal the specified values.

signal(IterableVvalues)SignalV

V
IterableVvalues

A list of values to emit.

SignalV

The Signal to emit sequential values.

Signal the specified values.

signal(SupplierVvalue)SignalV

V
SupplierVvalue

A value to emit.

SignalV

The Signal to emit sequential values.

Signal the specified values.

signalError(Throwableerror)SignalV

V
Throwableerror

An error to emit.

SignalV

The Signal to emit error.

Returns an Signal that invokes an Observer#error(Throwable) method when the Observer subscribes to it.

trace(Objectmsg)void

Objectmsg

A message log.

Write java.lang.System.Logger.Level#TRACE log.

trace(Stringname, Objectmsg)void

Stringname

A logger name.

Objectmsg

A message log.

Write java.lang.System.Logger.Level#TRACE log.

trace(WiseSuppliermsg)void

WiseSuppliermsg

A message log.

Write java.lang.System.Logger.Level#TRACE log.

trace(Stringname, WiseSuppliermsg)void

Stringname

A logger name.

WiseSuppliermsg

A message log.

Write java.lang.System.Logger.Level#TRACE log.

transform(Ininput, ClassOutoutput)Out

In

An input type you want to transform from.

Out

An output type you want to transform into.

Ininput

A target object.

ClassOutoutput

A target type.

Out

A transformed object.

Transform any type object into the specified type if possible.

translate(Stringtext, Objectcontext)VariableString

Stringtext

Basic English sentences.

Objectcontext

Parameters to be assigned to variables in a sentence. (Optional)

VariableString

The text will be automatically translated. Basic sentences must be written in English. It will be translated online automatically into the language specified in the global variable #Lang. Once the text is translated, it is saved to the local disk and loaded from there in the future.

translate(Disposabledisposer, Stringtext, Objectcontext)VariableString

Disposabledisposer
Stringtext

Basic English sentences.

Objectcontext

Parameters to be assigned to variables in a sentence. (Optional)

VariableString

The text will be automatically translated. Basic sentences must be written in English. It will be translated online automatically into the language specified in the global variable #Lang. Once the text is translated, it is saved to the local disk and loaded from there in the future.

type(Stringfqcn)Class

Stringfqcn

A fully qualified class name to want.

Class

The specified class.

Find the class by the specified fully qualified class name.

unwrap(Classtype)Class

Classtype

the class to convert to its primitive type (must not be null)

Class

the corresponding primitive class, or type itself if it's not a wrapper type

Returns the primitive type corresponding to the given wrapper class (boxed type). If the given class is not a wrapper type, the class itself is returned unchanged.

The mapping is as follows:

  • Boolean.class → boolean.class
  • Byte.class → byte.class
  • Character.class → char.class
  • Short.class → short.class
  • Integer.class → int.class
  • Long.class → long.class
  • Float.class → float.class
  • Double.class → double.class
  • Void.class → void.class

vouch(Tdefaults, Tvalues)T

T

A type of value.

Tdefaults

A default value.

Tvalues

A candidate of values.

T

A suitable value.

Obtains the last non-null value from the specified array. If there is no suitable value in the array or the array itself, the default value is retrieved.

warn(Objectmsg)void

Objectmsg

A message log.

Write java.lang.System.Logger.Level#WARNING log.

warn(Stringname, Objectmsg)void

Stringname

A logger name.

Objectmsg

A message log.

Write java.lang.System.Logger.Level#WARNING log.

warn(WiseSuppliermsg)void

WiseSuppliermsg

A message log.

Write java.lang.System.Logger.Level#WARNING log.

warn(Stringname, WiseSuppliermsg)void

Stringname

A logger name.

WiseSuppliermsg

A message log.

Write java.lang.System.Logger.Level#WARNING log.

wiseR(Runnablelambda)WiseRunnable

Runnablelambda

A target function.

WiseRunnable

A cast function.

Cast from Runnable to WiseRunnable.

void runnable() {
    Runnable lambda = () -> {
    };
    WiseRunnable dressed = I.wiseR(lambda);
    assert dressed != lambda;

    lambda = (WiseRunnable) () -> {
    };
    dressed = I.wiseR(lambda);
    assert dressed == lambda;
}

wiseC(ConsumerAlambda)WiseConsumerA

A
ConsumerAlambda

A target function.

WiseConsumerA

A cast function.

Cast from Consumer to WiseConsumer.

void consumer() {
    Consumer lambda = v -> {
    };
    WiseConsumer dressed = I.wiseC(lambda);
    assert dressed != lambda;

    lambda = (WiseConsumer) v -> {
    };
    dressed = I.wiseC(lambda);
    assert dressed == lambda;
}

wiseC(Runnablelambda)WiseConsumerA

A
Runnablelambda

A target function.

WiseConsumerA

A cast function.

Cast from Runnable to WiseConsumer. All missing parameters will be added on the right side. All additional caller arguments are ignored.

void consumerFromRunnable() throws Throwable {
    int[] counter = {0};
    WiseConsumer<String> consumer = I.wiseC(() -> counter[0]++);
    assert counter[0] == 0;

    consumer.accept("invoke as Consumer");
    assert counter[0] == 1;

    consumer.ACCEPT("invoke as WiseConsumer");
    assert counter[0] == 2;
}

wiseS(SupplierRlambda)WiseSupplierR

R
SupplierRlambda

A target function.

WiseSupplierR

A cast function.

Cast from Supplier to WiseSupplier.

void supplier() {
    Supplier lambda = () -> "";
    WiseSupplier dressed = I.wiseS(lambda);
    assert dressed != lambda;

    lambda = (WiseSupplier) () -> "";
    dressed = I.wiseS(lambda);
    assert dressed == lambda;
}

wiseS(Rconstant)WiseSupplierR

R
Rconstant

The fixed return value.

WiseSupplierR

A created function.

Create WiseSupplier which always return the specified value.

void supplierFromConstant() {
    WiseSupplier supplier = I.wiseS("constant");
    assert supplier.get().equals("constant");
}
void supplierFromNullConstant() {
    WiseSupplier supplier = I.wiseS((Object) null);
    assert supplier.get() == null;
}

wiseF(FunctionA, Rlambda)WiseFunctionA, R

A
R
FunctionA, Rlambda

A target function.

WiseFunctionA, R

A cast function.

Cast from Function to WiseFunction.

void function() {
    Function lambda = p -> "";
    WiseFunction dressed = I.wiseF(lambda);
    assert dressed != lambda;

    lambda = (WiseFunction) p -> "";
    dressed = I.wiseF(lambda);
    assert dressed == lambda;
}

wiseF(SupplierRlambda)WiseFunctionA, R

A
R
SupplierRlambda

A target function.

WiseFunctionA, R

A cast function.

Cast from Supplier to WiseFunction. All missing parameters will be added on the right side. All additional caller arguments are ignored.

void functionFromSupplier() {
    WiseFunction<String, String> function = I.wiseF(() -> "constant");
    assert function.apply("any value").equals("constant");
    assert function.apply("returns the fixed value").equals("constant");
}

wiseF(Rconstant)WiseFunctionA, R

A
R
Rconstant

The fixed return value.

WiseFunctionA, R

A created function.

Create WiseFunction which always return the specified value.

void functionFromConstant() {
    WiseFunction<String, String> function = I.wiseF("constant");
    assert function.apply("any value").equals("constant");
    assert function.apply("returns the fixed value").equals("constant");
}
void functionFromNullConstant() {
    WiseFunction<String, String> function = I.wiseF((String) null);
    assert function.apply("any value") == null;
    assert function.apply("returns the fixed value") == null;
}

wrap(Classtype)Class

Classtype

the class to convert to its wrapper type (must not be null)

Class

the corresponding wrapper class, or type itself if it's not primitive

Returns the wrapper class (boxed type) corresponding to the given primitive type. If the given class is not a primitive, the class itself is returned unchanged.

The mapping is as follows:

  • boolean.class → Boolean.class
  • byte.class → Byte.class
  • char.class → Character.class
  • short.class → Short.class
  • int.class → Integer.class
  • long.class → Long.class
  • float.class → Float.class
  • double.class → Double.class
  • void.class → Void.class

write(Objectinput)String

Objectinput

A Java object. All properties will be serialized deeply. null will throw java.lang.NullPointerException.

String

A JSON representation of Java object.

Write JSON representation of Java object.

write(Objectinput, Appendableoutput)void

Objectinput

A Java object. All properties will be serialized deeply. null will throw java.lang.NullPointerException.

Appendableoutput

A serialized data output. null will throw NullPointerException.

Write JSON representation of Java object to the specified output.

If the output object implements AutoCloseable, AutoCloseable#close() method will be invoked certainly.

write(Modelmodel, Objectinput, Appendableoutput)void

Modelmodel

A root model of the input object.

Objectinput

A Java object. All properties will be serialized deeply. null will throw java.lang.NullPointerException.

Appendableoutput

A serialized data output. null will throw NullPointerException.

Write JSON representation of Java object to the specified output.

If the output object implements AutoCloseable, AutoCloseable#close() method will be invoked certainly.

xml(Stringinput)XML

Stringinput

Text of xml representation.

XML

A constructed XML.

Parse the specified XML format text.

xml(Pathinput)XML

Pathinput

Path to the XML file.

XML

A constructed XML.

Parse the specified XML format text.

xml(InputStreaminput)XML

InputStreaminput

Text stream of xml representation.

XML

A constructed XML.

Parse the specified XML format text.

xml(Readerinput)XML

Readerinput

Text stream of xml representation.

XML

A constructed XML.

Parse the specified XML format text.

xml(Nodeinput)XML

Nodeinput

A xml expression.

XML

A constructed XML.

Parse the specified XML format text.

getActualTypeArguments()Type

Type

getRawType()Type

Type

getOwnerType()Type

Type