Package com.bakdata.util
Class FunctionalConstructor<T>
- java.lang.Object
-
- com.bakdata.util.FunctionalConstructor<T>
-
- Type Parameters:
T- the type of the class.
public final class FunctionalConstructor<T> extends java.lang.ObjectA lambda wrapper around the no-arg constructor of a class. The wrapped contructor can be used as a lambda withnew FunctionalConstructor(c)::invoke.
-
-
Constructor Summary
Constructors Constructor Description FunctionalConstructor(@NonNull java.lang.reflect.Constructor<T> ctor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)@NonNull java.lang.reflect.Constructor<T>getCtor()The no-arg constructorinthashCode()TnewInstance()Creates a new instance.java.lang.StringtoString()
-
-
-
Constructor Detail
-
FunctionalConstructor
public FunctionalConstructor(@NonNull @NonNull java.lang.reflect.Constructor<T> ctor)
-
-
Method Detail
-
newInstance
public T newInstance()
Creates a new instance.- Returns:
- the new instance.
- Throws:
java.lang.IllegalStateException- if anyInstantiationExceptionoccurs- Sneaky Throws:
- IllegalAccessException, Exception if any
InvocationTargetExceptionoccurs
-
getCtor
@NonNull public @NonNull java.lang.reflect.Constructor<T> getCtor()
The no-arg constructor
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-