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.Object
A 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 boolean
equals(java.lang.Object o)
@NonNull java.lang.reflect.Constructor<T>
getCtor()
The no-arg constructorint
hashCode()
T
newInstance()
Creates a new instance.java.lang.String
toString()
-
-
-
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 anyInstantiationException
occurs- Sneaky Throws:
- IllegalAccessException, Exception if any
InvocationTargetException
occurs
-
getCtor
@NonNull public @NonNull java.lang.reflect.Constructor<T> getCtor()
The no-arg constructor
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-