Class Setter

java.lang.Object
org.klojang.invoke.Setter

public final class Setter extends Object
Represents a setter for a single property.
Author:
Ayco Holleman
  • Method Details

    • getProperty

      public String getProperty()
      Returns the name of the property being set by this Setter.
      Returns:
      the name of the property being set by this Setter
    • getParamType

      public Class<?> getParamType()
      Returns the type of the property.
      Returns:
      the type of the property
    • write

      public void write(Object bean, Object value) throws IllegalAssignmentException, Throwable
      Sets the property on the specified bean to the specified value.
      Parameters:
      bean - the object receiving the value
      value - the value
      Throws:
      IllegalAssignmentException - If the value cannot be cast to the type of the property, or if the value is null and the property has a primitive type. This is a RuntimeException, but you might still want to catch it as it can often be handled in a meaningful way.
      Throwable - The unspecified Throwable associated with calls to MethodHandle.invoke.
    • illegalAssignment

      public IllegalAssignmentException illegalAssignment(Object value)
      Generates an IllegalAssignmentException indicating that the specified value cannot be assigned to the property encapsulated by this Setter.
      Parameters:
      value - the value
      Returns:
      An IllegalAssignmentException for the specified value