-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added letIntWith, letLongWith, letDoubleWith methods
- Loading branch information
Showing
8 changed files
with
486 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/com/plugatar/jkscope/function/ThToDoubleFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2024 Evgenii Plugatar | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.plugatar.jkscope.function; | ||
|
||
/** | ||
* The {@link java.util.function.Function} specialization that produces a {@code double}-valued result and might throw | ||
* an exception | ||
* | ||
* @param <T> the type of the input argument | ||
* @param <E> the type of the throwing exception | ||
* @see java.util.function.Function | ||
*/ | ||
@FunctionalInterface | ||
public interface ThToDoubleFunction<T, E extends Throwable> { | ||
|
||
/** | ||
* Applies this function to the given argument. | ||
* | ||
* @param t the input argument | ||
* @return result | ||
* @throws E if function threw exception | ||
*/ | ||
double apply(T t) throws E; | ||
|
||
/** | ||
* Returns this functions as an unchecked functions. | ||
* | ||
* @return unchecked function | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
default ThToDoubleFunction<T, RuntimeException> asUnchecked() { | ||
return (ThToDoubleFunction<T, RuntimeException>) this; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/plugatar/jkscope/function/ThToIntFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2024 Evgenii Plugatar | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.plugatar.jkscope.function; | ||
|
||
/** | ||
* The {@link java.util.function.Function} specialization that produces an {@code int}-valued result and might throw an | ||
* exception | ||
* | ||
* @param <T> the type of the input argument | ||
* @param <E> the type of the throwing exception | ||
* @see java.util.function.Function | ||
*/ | ||
@FunctionalInterface | ||
public interface ThToIntFunction<T, E extends Throwable> { | ||
|
||
/** | ||
* Applies this function to the given argument. | ||
* | ||
* @param t the input argument | ||
* @return result | ||
* @throws E if function threw exception | ||
*/ | ||
int apply(T t) throws E; | ||
|
||
/** | ||
* Returns this functions as an unchecked functions. | ||
* | ||
* @return unchecked function | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
default ThToIntFunction<T, RuntimeException> asUnchecked() { | ||
return (ThToIntFunction<T, RuntimeException>) this; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/plugatar/jkscope/function/ThToLongFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2024 Evgenii Plugatar | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.plugatar.jkscope.function; | ||
|
||
/** | ||
* The {@link java.util.function.Function} specialization that produces a {@code long}-valued result and might throw an | ||
* exception | ||
* | ||
* @param <T> the type of the input argument | ||
* @param <E> the type of the throwing exception | ||
* @see java.util.function.Function | ||
*/ | ||
@FunctionalInterface | ||
public interface ThToLongFunction<T, E extends Throwable> { | ||
|
||
/** | ||
* Applies this function to the given argument. | ||
* | ||
* @param t the input argument | ||
* @return result | ||
* @throws E if function threw exception | ||
*/ | ||
long apply(T t) throws E; | ||
|
||
/** | ||
* Returns this functions as an unchecked functions. | ||
* | ||
* @return unchecked function | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
default ThToLongFunction<T, RuntimeException> asUnchecked() { | ||
return (ThToLongFunction<T, RuntimeException>) this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.