diff --git a/src/main/java/xyz/zhouxy/plusone/commons/base/BoolRef.java b/src/main/java/xyz/zhouxy/plusone/commons/base/BoolRef.java index 56918ad..0527d74 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/base/BoolRef.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/base/BoolRef.java @@ -18,6 +18,7 @@ package xyz.zhouxy.plusone.commons.base; import com.google.common.annotations.Beta; +import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod; import xyz.zhouxy.plusone.commons.function.BoolUnaryOperator; @Beta @@ -29,6 +30,11 @@ public class BoolRef { this.value = value; } + @StaticFactoryMethod(BoolRef.class) + public static BoolRef of(boolean value) { + return new BoolRef(value); + } + public boolean getValue() { return value; } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/base/CharRef.java b/src/main/java/xyz/zhouxy/plusone/commons/base/CharRef.java index 929d4b4..35d409c 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/base/CharRef.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/base/CharRef.java @@ -18,6 +18,7 @@ package xyz.zhouxy.plusone.commons.base; import com.google.common.annotations.Beta; +import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod; import xyz.zhouxy.plusone.commons.function.CharUnaryOperator; @Beta @@ -29,6 +30,11 @@ public class CharRef { this.value = value; } + @StaticFactoryMethod(CharRef.class) + public static CharRef of(char value) { + return new CharRef(value); + } + public char getValue() { return value; } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/base/DoubleRef.java b/src/main/java/xyz/zhouxy/plusone/commons/base/DoubleRef.java index 9c476e5..addecb7 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/base/DoubleRef.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/base/DoubleRef.java @@ -20,6 +20,8 @@ import java.util.function.DoubleUnaryOperator; import com.google.common.annotations.Beta; +import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod; + @Beta public class DoubleRef { @@ -29,6 +31,11 @@ public class DoubleRef { this.value = value; } + @StaticFactoryMethod(DoubleRef.class) + public static DoubleRef of(double value) { + return new DoubleRef(value); + } + public double getValue() { return value; } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/base/IntRef.java b/src/main/java/xyz/zhouxy/plusone/commons/base/IntRef.java index 8f0148b..32b9b2b 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/base/IntRef.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/base/IntRef.java @@ -20,6 +20,8 @@ import java.util.function.IntUnaryOperator; import com.google.common.annotations.Beta; +import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod; + @Beta public class IntRef { @@ -29,6 +31,11 @@ public class IntRef { this.value = value; } + @StaticFactoryMethod(IntRef.class) + public static IntRef of(int value) { + return new IntRef(value); + } + public int getValue() { return value; } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/base/LongRef.java b/src/main/java/xyz/zhouxy/plusone/commons/base/LongRef.java index 7d079bd..4f4dd48 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/base/LongRef.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/base/LongRef.java @@ -20,6 +20,8 @@ import java.util.function.LongUnaryOperator; import com.google.common.annotations.Beta; +import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod; + @Beta public class LongRef { @@ -29,6 +31,11 @@ public class LongRef { this.value = value; } + @StaticFactoryMethod(LongRef.class) + public static LongRef of(long value) { + return new LongRef(value); + } + public long getValue() { return value; } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/base/Ref.java b/src/main/java/xyz/zhouxy/plusone/commons/base/Ref.java index 94c5ee4..28f6067 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/base/Ref.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/base/Ref.java @@ -22,6 +22,8 @@ import java.util.function.UnaryOperator; import com.google.common.annotations.Beta; +import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod; + @Beta public final class Ref { @@ -35,6 +37,16 @@ public final class Ref { this.value = value; } + @StaticFactoryMethod(Ref.class) + public static Ref of() { + return new Ref<>(); + } + + @StaticFactoryMethod(Ref.class) + public static Ref of(T value) { + return new Ref<>(value); + } + public T getValue() { return value; } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/function/BoolUnaryOperator.java b/src/main/java/xyz/zhouxy/plusone/commons/function/BoolUnaryOperator.java index eccef15..9da47a8 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/function/BoolUnaryOperator.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/function/BoolUnaryOperator.java @@ -21,9 +21,11 @@ import com.google.common.annotations.Beta; @Beta @FunctionalInterface public interface BoolUnaryOperator { + boolean applyAsBool(boolean operand); static BoolUnaryOperator not() { return b -> !b; } + } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/function/CharUnaryOperator.java b/src/main/java/xyz/zhouxy/plusone/commons/function/CharUnaryOperator.java index e9ca630..98bedcf 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/function/CharUnaryOperator.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/function/CharUnaryOperator.java @@ -21,5 +21,7 @@ import com.google.common.annotations.Beta; @Beta @FunctionalInterface public interface CharUnaryOperator { + char applyAsChar(char operand); + }