Skip to content

Commit 386ac51

Browse files
committed
✨ add functions
1 parent 30452e4 commit 386ac51

File tree

8 files changed

+147
-0
lines changed

8 files changed

+147
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<module>summer-beans</module>
1313
<module>summer-validator</module>
1414
<module>summer-engines</module>
15+
<module>summer-java-core</module>
1516
</modules>
1617

1718
<properties>

summer-java-core/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.dianpoint.summer</groupId>
8+
<artifactId>summer</artifactId>
9+
<version>0.1-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>summer-java-core</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>23</maven.compiler.source>
16+
<maven.compiler.target>23</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
</project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.dianpoint.summer;
2+
3+
/**
4+
* @author: congccoder
5+
* @email: congccoder@gmail.com | <a href="https://github.com/ccoderJava">github-homepage</a>
6+
* @date: 2025/6/5 20:39
7+
*/
8+
9+
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
10+
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
11+
public class Main {
12+
public static void main(String[] args) {
13+
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
14+
// to see how IntelliJ IDEA suggests fixing it.
15+
System.out.printf("Hello and welcome!");
16+
17+
for (int i = 1; i <= 5; i++) {
18+
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
19+
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
20+
System.out.println("i = " + i);
21+
}
22+
}
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.dianpoint.summer;
2+
3+
/**
4+
* @author: congccoder
5+
* @email: congccoder@gmail.com | <a href="https://github.com/ccoderJava">github-homepage</a>
6+
* @date: 2025/6/5 20:42
7+
*/
8+
9+
public interface Wrapper {
10+
11+
<T> T unwrap(Class<T> type) throws IllegalArgumentException;
12+
13+
boolean isWrapperFor(Class<?> type);
14+
15+
static <T> T tryUnwrap(Object object, Class<T> type) {
16+
if (object instanceof Wrapper) {
17+
Wrapper wrapper = (Wrapper) object;
18+
if (wrapper.isWrapperFor(type)) {
19+
return wrapper.unwrap(type);
20+
}
21+
}
22+
return null;
23+
}
24+
25+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.dianpoint.summer.lang;
2+
3+
import java.util.function.Predicate;
4+
5+
/**
6+
* @author: congccoder
7+
* @email: congccoder@gmail.com | <a href="https://github.com/ccoderJava">github-homepage</a>
8+
* @date: 2025/6/5 20:43
9+
*/
10+
11+
public interface Predicates {
12+
13+
Predicate[] EMPTY_PREDICATE_ARRAY = new Predicate[0];
14+
15+
16+
static <T> Predicate<T>[] emptyArray() {
17+
return (Predicate<T>[]) EMPTY_PREDICATE_ARRAY;
18+
}
19+
20+
21+
/**
22+
* {@link Predicate} always return <code>true</code>
23+
*
24+
* @param <T> the type to test
25+
* @return <code>true</code>
26+
*/
27+
static <T> Predicate<T> alwaysTrue() {
28+
return e -> true;
29+
}
30+
31+
/**
32+
* {@link Predicate} always return <code>false</code>
33+
*
34+
* @param <T> the type to test
35+
* @return <code>false</code>
36+
*/
37+
static <T> Predicate<T> alwaysFalse() {
38+
return e -> false;
39+
}
40+
41+
42+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.dianpoint.summer.lang;
2+
3+
/**
4+
* @author: congccoder
5+
* @email: congccoder@gmail.com | <a href="https://github.com/ccoderJava">github-homepage</a>
6+
* @date: 2025/6/5 20:43
7+
*/
8+
9+
public interface Streams {
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.dianpoint.summer.lang;
2+
3+
/**
4+
* @author: congccoder
5+
* @email: congccoder@gmail.com | <a href="https://github.com/ccoderJava">github-homepage</a>
6+
* @date: 2025/6/5 20:44
7+
*/
8+
9+
@FunctionalInterface
10+
public interface ThrowableAction {
11+
12+
void execute() throws Throwable;
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.dianpoint.summer.lang;
2+
3+
/**
4+
* @author: congccoder
5+
* @email: congccoder@gmail.com | <a href="https://github.com/ccoderJava">github-homepage</a>
6+
* @date: 2025/6/5 20:44
7+
*/
8+
9+
@FunctionalInterface
10+
public interface ThrowableSupplier<T> {
11+
12+
T get() throws Throwable;
13+
}

0 commit comments

Comments
 (0)