gitlab.com/evatix-go/core@v1.3.55/coreinstruction/FlatSpecification.go (about)

     1  package coreinstruction
     2  
     3  import "gitlab.com/evatix-go/core/coredata/stringslice"
     4  
     5  type FlatSpecification struct {
     6  	Id       string   `json:"Id"`
     7  	Display  string   `json:"Display"`
     8  	Type     string   `json:"Type"`
     9  	IsGlobal bool     `json:"IsGlobal"`
    10  	Tags     []string `json:"Tags,omitempty"`
    11  	IsValid  bool     `json:"IsValid,omitempty"`
    12  	spec     *Specification
    13  }
    14  
    15  func InvalidFlatSpecification() *FlatSpecification {
    16  	return &FlatSpecification{
    17  		Id:       "",
    18  		Display:  "",
    19  		Type:     "",
    20  		IsGlobal: false,
    21  		Tags:     []string{},
    22  		IsValid:  false,
    23  	}
    24  }
    25  
    26  func NewFlatSpecificationUsingSpec(spec *Specification, isValid bool) *FlatSpecification {
    27  	return &FlatSpecification{
    28  		Id:       spec.Id,
    29  		Display:  spec.Display,
    30  		Type:     spec.Type,
    31  		IsGlobal: spec.IsGlobal,
    32  		Tags:     spec.Tags,
    33  		IsValid:  isValid,
    34  		spec:     spec,
    35  	}
    36  }
    37  
    38  func (it *FlatSpecification) BaseIdentifier() BaseIdentifier {
    39  	return it.Spec().BaseIdentifier
    40  }
    41  
    42  func (it *FlatSpecification) BaseTags() BaseTags {
    43  	return it.Spec().BaseTags
    44  }
    45  
    46  func (it *FlatSpecification) BaseIsGlobal() BaseIsGlobal {
    47  	return it.Spec().BaseIsGlobal
    48  }
    49  
    50  func (it *FlatSpecification) BaseDisplay() BaseDisplay {
    51  	return it.Spec().BaseDisplay
    52  }
    53  
    54  func (it *FlatSpecification) BaseType() BaseType {
    55  	return it.Spec().BaseType
    56  }
    57  
    58  func (it *FlatSpecification) Spec() *Specification {
    59  	if it == nil {
    60  		return nil
    61  	}
    62  
    63  	if it.spec != nil {
    64  		return it.spec
    65  	}
    66  
    67  	it.spec = &Specification{
    68  		BaseIdDisplayType: BaseIdDisplayType{
    69  			BaseIdentifier: BaseIdentifier{Id: it.Id},
    70  			BaseDisplay:    BaseDisplay{it.Display},
    71  			BaseType:       BaseType{it.Type},
    72  		},
    73  		BaseTags: BaseTags{
    74  			Tags: it.Tags,
    75  		},
    76  		BaseIsGlobal: BaseIsGlobal{IsGlobal: it.IsGlobal},
    77  	}
    78  
    79  	return it.spec
    80  }
    81  
    82  func (it *FlatSpecification) Clone() *FlatSpecification {
    83  	if it == nil {
    84  		return nil
    85  	}
    86  
    87  	return &FlatSpecification{
    88  		Id:       it.Id,
    89  		Display:  it.Display,
    90  		Type:     it.Type,
    91  		IsGlobal: it.IsGlobal,
    92  		Tags:     stringslice.Clone(it.Tags),
    93  		IsValid:  it.IsValid,
    94  	}
    95  }