gitlab.com/evatix-go/core@v1.3.55/coreinterface/loggerinf/ReflectSetter.go (about)

     1  package loggerinf
     2  
     3  // ReflectSetter
     4  //
     5  // ReflectSetTo
     6  //  sets current object to something else by casting,
     7  //  reflection, by unmarshalling or by marshalling
     8  //
     9  // Set any object from to toPointer object
    10  //
    11  // Valid Inputs or Supported (https://t.ly/1Lpt):
    12  //  - From, To: (null, null)                          -- do nothing
    13  //  - From, To: (sameTypePointer, sameTypePointer)    -- try reflection
    14  //  - From, To: (sameTypeNonPointer, sameTypePointer) -- try reflection
    15  //  - From, To: ([]byte or *[]byte, otherType)        -- try unmarshal, reflect
    16  //  - From, To: (otherType, *[]byte)                  -- try marshal, reflect
    17  //
    18  // Validations:
    19  //  - Check null, if both null no error return quickly.
    20  //  - NotSupported returns as error.
    21  //      - NotSupported: (from, to) - (..., not pointer)
    22  //      - NotSupported: (from, to) - (null, notNull)
    23  //      - NotSupported: (from, to) - (notNull, null)
    24  //      - NotSupported: (from, to) - not same type and not bytes on any
    25  //  - `From` null or nil is not supported and will return error.
    26  //
    27  // Reference:
    28  //  - Reflection String Set Example : https://go.dev/play/p/fySLYuOvoRK.go?download=true
    29  //  - Method document screenshot    : https://prnt.sc/26dmf5g
    30  type ReflectSetter interface {
    31  	// ReflectSetTo
    32  	//
    33  	// ReflectSetter
    34  	//  sets current object to something else by casting,
    35  	//  reflection, by unmarshalling or by marshalling
    36  	//
    37  	// Set any object from to toPointer object
    38  	//
    39  	// Valid Inputs or Supported (https://t.ly/1Lpt):
    40  	//  - From, To: (null, null)                          -- do nothing
    41  	//  - From, To: (sameTypePointer, sameTypePointer)    -- try reflection
    42  	//  - From, To: (sameTypeNonPointer, sameTypePointer) -- try reflection
    43  	//  - From, To: ([]byte or *[]byte, otherType)        -- try unmarshal, reflect
    44  	//  - From, To: (otherType, *[]byte)                  -- try marshal, reflect
    45  	//
    46  	// Validations:
    47  	//  - Check null, if both null no error return quickly.
    48  	//  - NotSupported returns as error.
    49  	//      - NotSupported: (from, to) - (..., not pointer)
    50  	//      - NotSupported: (from, to) - (null, notNull)
    51  	//      - NotSupported: (from, to) - (notNull, null)
    52  	//      - NotSupported: (from, to) - not same type and not bytes on any
    53  	//  - `From` null or nil is not supported and will return error.
    54  	//
    55  	// Reference:
    56  	//  - Reflection String Set Example : https://go.dev/play/p/fySLYuOvoRK.go?download=true
    57  	//  - Method document screenshot    : https://prnt.sc/26dmf5g
    58  	ReflectSetTo(toPointer interface{}) error
    59  }