forked from plusone/plusone-commons
Ref 类添加 of 方法
parent
6ba06d7ea1
commit
d11b025c69
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<T> {
|
||||
|
||||
|
@ -35,6 +37,16 @@ public final class Ref<T> {
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
@StaticFactoryMethod(Ref.class)
|
||||
public static <T> Ref<T> of() {
|
||||
return new Ref<>();
|
||||
}
|
||||
|
||||
@StaticFactoryMethod(Ref.class)
|
||||
public static <T> Ref<T> of(T value) {
|
||||
return new Ref<>(value);
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,5 +21,7 @@ import com.google.common.annotations.Beta;
|
|||
@Beta
|
||||
@FunctionalInterface
|
||||
public interface CharUnaryOperator {
|
||||
|
||||
char applyAsChar(char operand);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue