Class ReflectionHelper

java.lang.Object
team.lodestar.lodestone.helpers.ReflectionHelper

public class ReflectionHelper extends Object
  • Constructor Details

    • ReflectionHelper

      public ReflectionHelper()
  • Method Details

    • copyFields

      public static <T> void copyFields(T from, T to, String... fieldNames)
      Copies fields from one object to another.
      Parameters:
      fieldNames - The names of the fields to absorb. If empty, all fields will be absorbed.
    • getField

      public static <T> Optional<T> getField(String name, Object object)
      Gets a field from an object, regardless of access restrictions. Returns empty optional if invalid.
      Parameters:
      name - The name of the field.
      object - The object to get the field from.