package framework

type Cloneable interface {
	CloneableClone() Cloneable
}

type CloneableString string

func (cs CloneableString) CloneableClone() Cloneable {
	return cs
}

type CloneableStrings []string

func (css CloneableStrings) CloneableClone() Cloneable {
	return css
}

type CloneableInt int

func (ci CloneableInt) CloneableClone() Cloneable {
	return ci
}

type CloneableBool bool

func (cb CloneableBool) CloneableClone() Cloneable {
	return cb
}

// TODO: error type is changed during clone, which might cause something wrong
type CloneableError struct {
	err string
}

func NewCloneableError(e error) *CloneableError {
	if e == nil {
		return nil
	}
	return &CloneableError{
		err: e.Error(),
	}
}

func (ce *CloneableError) String() string {
	return ce.err
}

func (ce *CloneableError) Error() string {
	return ce.err
}

func (ce *CloneableError) CloneableClone() Cloneable {
	return ce
}
