添加注释。

feature/net-util
ZhouXY108 2023-04-30 10:48:48 +08:00
parent 025e8ac4da
commit 06fb0e7a4d
13 changed files with 366 additions and 0 deletions

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.Optional; import java.util.Optional;
import java.util.function.DoubleFunction; import java.util.function.DoubleFunction;
/**
* DoubleToOptionalFunction
*
* <p>
* double {@code Optional&lt;R&gt;}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see Optional
* @see DoubleFunction
*/
@FunctionalInterface @FunctionalInterface
public interface DoubleToOptionalFunction<R> extends DoubleFunction<Optional<R>> { public interface DoubleToOptionalFunction<R> extends DoubleFunction<Optional<R>> {
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.Optional; import java.util.Optional;
import java.util.function.IntFunction; import java.util.function.IntFunction;
/**
* IntToOptionalFunction
*
* <p>
* int {@code Optional&lt;R&gt;}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see Optional
* @see IntFunction
*/
@FunctionalInterface @FunctionalInterface
public interface IntToOptionalFunction<R> extends IntFunction<Optional<R>> { public interface IntToOptionalFunction<R> extends IntFunction<Optional<R>> {
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.Optional; import java.util.Optional;
import java.util.function.LongFunction; import java.util.function.LongFunction;
/**
* LongToOptionalFunction
*
* <p>
* long {@code Optional&lt;R&gt;}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see Optional
* @see LongFunction
*/
@FunctionalInterface @FunctionalInterface
public interface LongToOptionalFunction<R> extends LongFunction<Optional<R>> { public interface LongToOptionalFunction<R> extends LongFunction<Optional<R>> {
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.OptionalDouble; import java.util.OptionalDouble;
import java.util.function.Supplier; import java.util.function.Supplier;
/**
* OptionalDoubleSupplier
*
* <p>
* {@link OptionalDouble}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see OptionalDouble
* @see Supplier
*/
@FunctionalInterface @FunctionalInterface
public interface OptionalDoubleSupplier extends Supplier<OptionalDouble> { public interface OptionalDoubleSupplier extends Supplier<OptionalDouble> {
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.OptionalInt; import java.util.OptionalInt;
import java.util.function.Supplier; import java.util.function.Supplier;
/**
* OptionalIntSupplier
*
* <p>
* {@link OptionalInt}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see OptionalInt
* @see Supplier
*/
@FunctionalInterface @FunctionalInterface
public interface OptionalIntSupplier extends Supplier<OptionalInt> { public interface OptionalIntSupplier extends Supplier<OptionalInt> {
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.OptionalLong; import java.util.OptionalLong;
import java.util.function.Supplier; import java.util.function.Supplier;
/**
* OptionalLongSupplier
*
* <p>
* {@link OptionalLong}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see OptionalLong
* @see Supplier
*/
@FunctionalInterface @FunctionalInterface
public interface OptionalLongSupplier extends Supplier<OptionalLong> { public interface OptionalLongSupplier extends Supplier<OptionalLong> {
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.Optional; import java.util.Optional;
import java.util.function.Supplier; import java.util.function.Supplier;
/**
* OptionalSupplier
*
* <p>
* {@code Optional&lt;T&gt;}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see Optional
* @see Supplier
*/
@FunctionalInterface @FunctionalInterface
public interface OptionalSupplier<T> extends Supplier<Optional<T>> { public interface OptionalSupplier<T> extends Supplier<Optional<T>> {
} }

View File

@ -1,9 +1,51 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.function.Predicate; import java.util.function.Predicate;
/**
* Predicates
*
* <p>
* {@link Predicate}
* </p>
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see Predicate
*/
public class Predicates { public class Predicates {
/**
* lambda {@link Predicate}
* {@code Objects::nonNull} {@code Predicate&lt;String&gt;}
* 使 {@link Predicate#and(Predicate)}{@link Predicate#or(Predicate)}
* {@code Predicate<? super String>}
*
* <pre>
* Predicate&lt;String&gt; predicate = Predicates.&lt;String&gt;of(Objects::nonNull)
* .and(StringUtils::isNotEmpty);
* </pre>
*
* @param <T>
* @param predicate
* @return
*/
public static <T> Predicate<T> of(Predicate<? super T> predicate) { public static <T> Predicate<T> of(Predicate<? super T> predicate) {
return predicate::test; return predicate::test;
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.Optional; import java.util.Optional;
import java.util.function.BiFunction; import java.util.function.BiFunction;
/**
* ToOptionalBiFunction
*
* <p>
* T U {@code Optional&lt;R&gt;}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see Optional
* @see BiFunction
*/
@FunctionalInterface @FunctionalInterface
public interface ToOptionalBiFunction<T, U, R> extends BiFunction<T, U, Optional<R>> { public interface ToOptionalBiFunction<T, U, R> extends BiFunction<T, U, Optional<R>> {
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.OptionalDouble; import java.util.OptionalDouble;
import java.util.function.Function; import java.util.function.Function;
/**
* ToOptionalDoubleFunction
*
* <p>
* T {@link OptionalDouble}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see OptionalDouble
* @see Function
*/
@FunctionalInterface @FunctionalInterface
public interface ToOptionalDoubleFunction<T> extends Function<T, OptionalDouble> { public interface ToOptionalDoubleFunction<T> extends Function<T, OptionalDouble> {
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.Optional; import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
/**
* ToOptionalFunction
*
* <p>
* T {@code Optional&lt;R&gt;}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see Optional
* @see Function
*/
@FunctionalInterface @FunctionalInterface
public interface ToOptionalFunction<T, R> extends Function<T, Optional<R>> { public interface ToOptionalFunction<T, R> extends Function<T, Optional<R>> {
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.OptionalInt; import java.util.OptionalInt;
import java.util.function.Function; import java.util.function.Function;
/**
* ToOptionalIntFunction
*
* <p>
* T {@link OptionalInt}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see OptionalInt
* @see Function
*/
@FunctionalInterface @FunctionalInterface
public interface ToOptionalIntFunction<T> extends Function<T, OptionalInt> { public interface ToOptionalIntFunction<T> extends Function<T, OptionalInt> {
} }

View File

@ -1,8 +1,35 @@
/*
* Copyright 2022-2023 the original author or authors.
*
* 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
*
* https://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 xyz.zhouxy.plusone.commons.function; package xyz.zhouxy.plusone.commons.function;
import java.util.OptionalLong; import java.util.OptionalLong;
import java.util.function.Function; import java.util.function.Function;
/**
* ToOptionalLongFunction
*
* <p>
* T {@link OptionalLong}
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @since 0.1.0
* @see OptionalLong
* @see Function
*/
@FunctionalInterface @FunctionalInterface
public interface ToOptionalLongFunction<T> extends Function<T, OptionalLong> { public interface ToOptionalLongFunction<T> extends Function<T, OptionalLong> {
} }