Class ObjectReconstructor<T>

java.lang.Object
com.comphenix.protocol.utility.ObjectReconstructor<T>
Type Parameters:
T - The type of the object to reconstruct.

public class ObjectReconstructor<T> extends Object
This class can be used to reconstruct objects. Note that it is limited to classes where both the order and number of member variables matches the order and number of arguments for the first constructor. This means that this class is mostly useful for classes generated by lambdas.
Author:
Pim
  • Constructor Details

    • ObjectReconstructor

      public ObjectReconstructor(Class<T> clz)
  • Method Details

    • getValues

      public Object[] getValues(Object instance)
      Gets the values of all member variables of the provided instance.
      Parameters:
      instance - The instance for which to get all the member variables.
      Returns:
      The values of the member variables from the instance.
    • getFields

      public Field[] getFields()
      Gets the fields in the class.
      Returns:
      The fields.
    • reconstruct

      public T reconstruct(Object[] values)
      Creates a new instance of the class using the new values.
      Parameters:
      values - The new values for the member variables of the class.
      Returns:
      The new instance.