Class POWrapper

java.lang.Object
org.adempiere.model.POWrapper
All Implemented Interfaces:
InvocationHandler

public class POWrapper extends Object implements InvocationHandler
Wrap a PO object to a given interface.
Example usage:
 public interface I_C_Invoice_Customized
 {
        public int getCustomValue1();
        public void setCustomValue1(int customValue1);
        public String getCustomString1();
        public void setCustomString1(String customString1);
 }
 ....
 MInvoice invoice = ......;
 I_C_Invoice_Customized invoiceCustomized = POWrapper.create(invoice, I_C_Invoice_Customized.class);
 invoiceCustomized.setCustomValue1(12345);
 invoiceCustomized.setCustomString1("my test string");
 invoice.saveEx();
 
Author:
Teo Sarca, teo.sarca@gmail.com
  • Method Details

    • create

      public static <T> T create(Object po, Class<T> cl)
      Create wrapper of type cl for po
      Type Parameters:
      T - iDempiere model interface type
      Parameters:
      po -
      cl - iDempiere model interface class
      Returns:
      wrapped instance
    • getPO

      public static <T extends PO> T getPO(Object model)
      Get wrapped PO instance
      Type Parameters:
      T -
      Parameters:
      model -
      Returns:
      the wrapped PO
    • invoke

      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
      Specified by:
      invoke in interface InvocationHandler
      Throws:
      Throwable
    • getPO

      public PO getPO()
      Returns:
      wrapped PO instance