diff --git a/bytetype/bytetype.go b/bytetype/bytetype.go index 38a90e7f4dd3a79d5f8f5257a489d10fad7b25e7..4383aac8fa8864a40620d15fc052163f722e9a3a 100644 --- a/bytetype/bytetype.go +++ b/bytetype/bytetype.go @@ -1,12 +1,20 @@ package bytetype import ( + "gitlab.com/evatix-go/core/coredata/corejson" "gitlab.com/evatix-go/core/coreinterface" - "gitlab.com/evatix-go/core/errcore" ) type Variant byte +func (it Variant) IsValid() bool { + return it != 0 +} + +func (it Variant) IsInvalid() bool { + return it == 0 +} + func (it Variant) NameValue() string { return BasicEnumImpl.NameWithValue(it) } @@ -20,15 +28,35 @@ func (it Variant) Name() string { } func (it Variant) UnmarshallToValue(jsonUnmarshallingValue []byte) (byte, error) { - panic("implement me") + newEmpty := Variant(0) + err := corejson. + Deserialize. + UsingBytes( + jsonUnmarshallingValue, &newEmpty) + + if err != nil { + return 0, err + } + + return newEmpty.Value(), nil } func (it Variant) MarshalJSON() ([]byte, error) { return BasicEnumImpl.ToEnumJsonBytes(it.Value()), nil } -func (it Variant) UnmarshalJSON(data []byte) error { - panic(errcore.NotImplementedType.ErrorNoRefs("UnmarshalJSON not implemented for bytetype.")) +func (it *Variant) UnmarshalJSON(data []byte) error { + newEmpty := Variant(0) + err := corejson. + Deserialize. + UsingBytes( + data, &newEmpty) + + if err == nil { + *it = newEmpty + } + + return err } func (it Variant) String() string { @@ -156,5 +184,5 @@ func (it Variant) TypeName() string { } func (it Variant) AsBasicEnumContractsBinder() coreinterface.BasicEnumContractsBinder { - return it + return &it } diff --git a/chmodhelper/chmodclasstype/Variant.go b/chmodhelper/chmodclasstype/Variant.go index 3cff674b3577c2e60338289e479f5277d131c4ac..4fe6b7a5cb37a2bfb2a473706d04d1d89c159cf1 100644 --- a/chmodhelper/chmodclasstype/Variant.go +++ b/chmodhelper/chmodclasstype/Variant.go @@ -7,7 +7,7 @@ import ( type Variant byte const ( - UnInitialized Variant = iota + Invalid Variant = iota All Owner Group @@ -18,7 +18,7 @@ const ( ) func (it Variant) IsUnInitialized() bool { - return it == UnInitialized + return it == Invalid } func (it Variant) IsAll() bool { @@ -49,6 +49,14 @@ func (it Variant) IsOwnerOther() bool { return it == OwnerOther } +func (it Variant) IsValid() bool { + return it != Invalid +} + +func (it Variant) IsInvalid() bool { + return it == Invalid +} + func (it *Variant) Name() string { return BasicEnumImpl.ToEnumString(it.ValueByte()) } diff --git a/chmodhelper/chmodclasstype/vars.go b/chmodhelper/chmodclasstype/vars.go index 9ad59a838c8796e5bcdfd4e26339d24bc3686bdd..5ef08a24940f0ec42e7fdf513c78f8126c6c1962 100644 --- a/chmodhelper/chmodclasstype/vars.go +++ b/chmodhelper/chmodclasstype/vars.go @@ -7,17 +7,17 @@ import ( var ( Ranges = [...]string{ - UnInitialized: "UnInitialized", - All: "All", - Owner: "Owner", - Group: "Group", - Other: "Other", - OwnerGroup: "OwnerGroup", - GroupOther: "GroupOther", - OwnerOther: "OwnerOther", + Invalid: "Invalid", + All: "All", + Owner: "Owner", + Group: "Group", + Other: "Other", + OwnerGroup: "OwnerGroup", + GroupOther: "GroupOther", + OwnerOther: "OwnerOther", } BasicEnumImpl = enumimpl.NewBasicByteUsingIndexedSlice( - reflectinternal.TypeName(UnInitialized), + reflectinternal.TypeName(Invalid), Ranges[:]) ) diff --git a/constants/messages-formats.go b/constants/messages-formats.go index b4173c40a7eed8e9df9922518a1be97505f99298..406e360913ca09f5d66ab8490eae574a2c64fc3e 100644 --- a/constants/messages-formats.go +++ b/constants/messages-formats.go @@ -49,6 +49,9 @@ const ( StringWithDoubleQuoteFormat = "\"%s\"" StringWithSingleQuoteFormat = "'%s'" MessageWrapMessageFormat = "%s (%s)" + FromToFormat = "{From : %q, To: %q}" // From, To name + SourceDestinationFormat = "{Source : %q, Destination: %q}" // source, destination + RenameFormat = "{Existing : %q, New: %q}" // existing, new ValueWrapValueFormat = "%v (%v)" FilePathEmpty = "File path was empty(\"\")." EnumOnlySupportedFormat = "enum: %T, " + diff --git a/corecsv/AnyItemsToCsvString.go b/corecsv/AnyItemsToCsvString.go index 364d803e1c94c6ba2c1ae3ce48b485d358c2ac16..edc7bd1637ab6ccfb22dbf5cc8a4eb0beabde8d4 100644 --- a/corecsv/AnyItemsToCsvString.go +++ b/corecsv/AnyItemsToCsvString.go @@ -19,7 +19,7 @@ import ( func AnyItemsToCsvString( joiner string, isIncludeQuote, - isIncludeSingleQuote bool, + isIncludeSingleQuote bool, // disable this will give double quote references ...interface{}, ) string { if len(references) == 0 { diff --git a/corecsv/AnyItemsToCsvStrings.go b/corecsv/AnyItemsToCsvStrings.go index 91f52f606f0fdeb76b335c60ff55730481745730..7638b6a2981782924df6dfa2d00d632841962e52 100644 --- a/corecsv/AnyItemsToCsvStrings.go +++ b/corecsv/AnyItemsToCsvStrings.go @@ -14,7 +14,7 @@ import ( // - !isIncludeQuote && !isIncludeSingleQuote = %v will be added func AnyItemsToCsvStrings( isIncludeQuote, - isIncludeSingleQuote bool, + isIncludeSingleQuote bool, // disable this will give double quote references ...interface{}, ) []string { if len(references) == 0 { diff --git a/corecsv/CompileStringersToCsvStrings.go b/corecsv/CompileStringersToCsvStrings.go index 6685a56ce97e893fa51d8548596e476dd8330c58..95d2b2df29c3fcd67bb0c1dc2b2d02e3ef86c0d0 100644 --- a/corecsv/CompileStringersToCsvStrings.go +++ b/corecsv/CompileStringersToCsvStrings.go @@ -14,7 +14,7 @@ import ( // - !isIncludeQuote && !isIncludeSingleQuote = %v will be added func CompileStringersToCsvStrings( isIncludeQuote, - isIncludeSingleQuote bool, + isIncludeSingleQuote bool, // disable this will give double quote compileStringerFunctions ...func() string, ) []string { if len(compileStringerFunctions) == 0 { diff --git a/corecsv/CompileStringersToString.go b/corecsv/CompileStringersToString.go index 92531b6400c9ff7b11372f5838ff4ea56be843d6..69e47fdcdcf72d47c65f1a8dfad4c674b908f3f7 100644 --- a/corecsv/CompileStringersToString.go +++ b/corecsv/CompileStringersToString.go @@ -5,7 +5,7 @@ import "strings" func CompileStringersToString( joiner string, isIncludeQuote, - isIncludeSingleQuote bool, + isIncludeSingleQuote bool, // disable this will give double quote compileStringerFunctions ...func() string, ) string { slice := CompileStringersToCsvStrings( diff --git a/corecsv/StringersToCsvStrings.go b/corecsv/StringersToCsvStrings.go index 9cd2f9fd9c4cb594a877a2f0facc46e1fb2257ed..2b2e86eab6710ab577a0f5d14ccf4e882c8a66d8 100644 --- a/corecsv/StringersToCsvStrings.go +++ b/corecsv/StringersToCsvStrings.go @@ -14,7 +14,7 @@ import ( // - !isIncludeQuote && !isIncludeSingleQuote = %v will be added func StringersToCsvStrings( isIncludeQuote, - isIncludeSingleQuote bool, + isIncludeSingleQuote bool, // disable this will give double quote stringerFunctions ...fmt.Stringer, ) []string { if len(stringerFunctions) == 0 { diff --git a/corecsv/StringersToString.go b/corecsv/StringersToString.go index ae7209dddc9de7acf4168cad5997fb7c4b72fa2a..694a50dfb8adbda5c7e614918cf8e7734540e8d9 100644 --- a/corecsv/StringersToString.go +++ b/corecsv/StringersToString.go @@ -8,7 +8,7 @@ import ( func StringersToString( joiner string, isIncludeQuote, - isIncludeSingleQuote bool, + isIncludeSingleQuote bool, // disable this will give double quote stringerFunctions ...fmt.Stringer, ) string { slice := StringersToCsvStrings( diff --git a/corecsv/StringsToCsvString.go b/corecsv/StringsToCsvString.go index 7e7651b37ca12de4bedbb03dd87016ddcbce71fb..0eb2683de2b3b323cc6217df3831d68321f169bf 100644 --- a/corecsv/StringsToCsvString.go +++ b/corecsv/StringsToCsvString.go @@ -19,7 +19,7 @@ import ( func StringsToCsvString( joiner string, isIncludeQuote, - isIncludeSingleQuote bool, + isIncludeSingleQuote bool, // disable this will give double quote references ...string, ) string { if len(references) == 0 { diff --git a/corecsv/StringsToCsvStrings.go b/corecsv/StringsToCsvStrings.go index 16b93b12f92e5dc6244656736e3d97623f00168b..fbc5df1bc9559def727d4a7005799c69b2b0c6d1 100644 --- a/corecsv/StringsToCsvStrings.go +++ b/corecsv/StringsToCsvStrings.go @@ -14,7 +14,7 @@ import ( // - !isIncludeQuote && !isIncludeSingleQuote = %v will be added func StringsToCsvStrings( isIncludeQuote, - isIncludeSingleQuote bool, + isIncludeSingleQuote bool, // disable this will give double quote references ...string, ) []string { if len(references) == 0 { diff --git a/corefuncs/funcs.go b/corefuncs/funcs.go index 2b743973df1d5936cc79e1dc3704889cde23899a..9a7d195dd1f322590e61cd6790b1bf5efd628756 100644 --- a/corefuncs/funcs.go +++ b/corefuncs/funcs.go @@ -13,7 +13,8 @@ type ( IsApplyFunc func() (isSuccess bool) InOutFunc func(input interface{}) (output interface{}) InOutErrFunc func(input interface{}) (output interface{}, err error) - DeserializeOutputFunc func(input interface{}) (deserializedBytes []byte, err error) + SerializeOutputFunc func(input interface{}) (serializedBytes []byte, err error) + SerializerVoidFunc func() (serializedBytes []byte, err error) InActionReturnsErrFunc func(input interface{}) (err error) NamedActionFunc func(name string) ActionReturnsErrorFunc func() error diff --git a/coreinstruction/BaseFromTo.go b/coreinstruction/BaseFromTo.go index b3915393053c77c71ab627c374514fe5494f7777..1512fced5a2a90e28324a192ecdff0870399ccb0 100644 --- a/coreinstruction/BaseFromTo.go +++ b/coreinstruction/BaseFromTo.go @@ -1,6 +1,5 @@ package coreinstruction type BaseFromTo struct { - From string `json:"From,omitempty"` - To string `json:"To,omitempty"` + FromTo } diff --git a/coreinstruction/BaseSourceDestination.go b/coreinstruction/BaseSourceDestination.go new file mode 100644 index 0000000000000000000000000000000000000000..9d30ad52bd6274f40c74fedbb589b7bf3c6a99e5 --- /dev/null +++ b/coreinstruction/BaseSourceDestination.go @@ -0,0 +1,5 @@ +package coreinstruction + +type BaseSourceDestination struct { + SourceDestination +} diff --git a/coreinstruction/BaseTags.go b/coreinstruction/BaseTags.go index 3d629d2c37cdd405f8632b88a53211c1ac2f5e43..13f9572f6fddf19a3c84caa1b8dc5061551f8f62 100644 --- a/coreinstruction/BaseTags.go +++ b/coreinstruction/BaseTags.go @@ -9,7 +9,7 @@ import ( type BaseTags struct { tagsHashset *corestr.Hashset - Tags *[]string `json:"Tags,omitempty"` + Tags []string `json:"Tags,omitempty"` } func NewTagsPtr(tags *[]string) *BaseTags { @@ -23,12 +23,12 @@ func NewTagsPtr(tags *[]string) *BaseTags { func NewTags(tags []string) *BaseTags { if len(tags) == 0 { return &BaseTags{ - Tags: &[]string{}, + Tags: []string{}, } } return &BaseTags{ - Tags: &tags, + Tags: tags, } } @@ -37,7 +37,7 @@ func (it BaseTags) TagsLength() int { return constants.Zero } - return len(*it.Tags) + return len(it.Tags) } func (it BaseTags) IsTagsEmpty() bool { @@ -49,7 +49,7 @@ func (it BaseTags) TagsHashset() *corestr.Hashset { return it.tagsHashset } - it.tagsHashset = corestr.New.Hashset.StringsPtr( + it.tagsHashset = corestr.New.Hashset.Strings( it.Tags) return it.tagsHashset @@ -80,7 +80,7 @@ func (it BaseTags) IsAnyTagMatchesRegex(regexp2 *regexp.Regexp) bool { return false } - for _, s := range *it.Tags { + for _, s := range it.Tags { if regexp2.MatchString(s) { return true } diff --git a/coreinstruction/FlatSpecification.go b/coreinstruction/FlatSpecification.go index d7aff32831f216abb910a4e3995dd368c30e7257..776955b6cb25a4203b63a58a03ae7d2de72b227f 100644 --- a/coreinstruction/FlatSpecification.go +++ b/coreinstruction/FlatSpecification.go @@ -3,12 +3,12 @@ package coreinstruction import "gitlab.com/evatix-go/core/coredata/stringslice" type FlatSpecification struct { - Id string `json:"Id"` - Display string `json:"Display"` - Type string `json:"Type"` - IsGlobal bool `json:"IsGlobal"` - Tags *[]string `json:"Tags,omitempty"` - IsValid bool `json:"IsValid,omitempty"` + Id string `json:"Id"` + Display string `json:"Display"` + Type string `json:"Type"` + IsGlobal bool `json:"IsGlobal"` + Tags []string `json:"Tags,omitempty"` + IsValid bool `json:"IsValid,omitempty"` spec *Specification } @@ -18,7 +18,7 @@ func InvalidFlatSpecification() *FlatSpecification { Display: "", Type: "", IsGlobal: false, - Tags: &[]string{}, + Tags: []string{}, IsValid: false, } } @@ -35,61 +35,61 @@ func NewFlatSpecificationUsingSpec(spec *Specification, isValid bool) *FlatSpeci } } -func (receiver *FlatSpecification) BaseIdentifier() BaseIdentifier { - return receiver.Spec().BaseIdentifier +func (it *FlatSpecification) BaseIdentifier() BaseIdentifier { + return it.Spec().BaseIdentifier } -func (receiver *FlatSpecification) BaseTags() BaseTags { - return receiver.Spec().BaseTags +func (it *FlatSpecification) BaseTags() BaseTags { + return it.Spec().BaseTags } -func (receiver *FlatSpecification) BaseIsGlobal() BaseIsGlobal { - return receiver.Spec().BaseIsGlobal +func (it *FlatSpecification) BaseIsGlobal() BaseIsGlobal { + return it.Spec().BaseIsGlobal } -func (receiver *FlatSpecification) BaseDisplay() BaseDisplay { - return receiver.Spec().BaseDisplay +func (it *FlatSpecification) BaseDisplay() BaseDisplay { + return it.Spec().BaseDisplay } -func (receiver *FlatSpecification) BaseType() BaseType { - return receiver.Spec().BaseType +func (it *FlatSpecification) BaseType() BaseType { + return it.Spec().BaseType } -func (receiver *FlatSpecification) Spec() *Specification { - if receiver == nil { +func (it *FlatSpecification) Spec() *Specification { + if it == nil { return nil } - if receiver.spec != nil { - return receiver.spec + if it.spec != nil { + return it.spec } - receiver.spec = &Specification{ + it.spec = &Specification{ BaseIdDisplayType: BaseIdDisplayType{ - BaseIdentifier: BaseIdentifier{Id: receiver.Id}, - BaseDisplay: BaseDisplay{receiver.Display}, - BaseType: BaseType{receiver.Type}, + BaseIdentifier: BaseIdentifier{Id: it.Id}, + BaseDisplay: BaseDisplay{it.Display}, + BaseType: BaseType{it.Type}, }, BaseTags: BaseTags{ - Tags: receiver.Tags, + Tags: it.Tags, }, - BaseIsGlobal: BaseIsGlobal{IsGlobal: receiver.IsGlobal}, + BaseIsGlobal: BaseIsGlobal{IsGlobal: it.IsGlobal}, } - return receiver.spec + return it.spec } -func (receiver *FlatSpecification) Clone() *FlatSpecification { - if receiver == nil { +func (it *FlatSpecification) Clone() *FlatSpecification { + if it == nil { return nil } return &FlatSpecification{ - Id: receiver.Id, - Display: receiver.Display, - Type: receiver.Type, - IsGlobal: receiver.IsGlobal, - Tags: stringslice.ClonePtr(receiver.Tags), - IsValid: receiver.IsValid, + Id: it.Id, + Display: it.Display, + Type: it.Type, + IsGlobal: it.IsGlobal, + Tags: stringslice.Clone(it.Tags), + IsValid: it.IsValid, } } diff --git a/coreinstruction/FromTo.go b/coreinstruction/FromTo.go new file mode 100644 index 0000000000000000000000000000000000000000..0b32d74f299a07a7374a82a6174ada0e76aae187 --- /dev/null +++ b/coreinstruction/FromTo.go @@ -0,0 +1,68 @@ +package coreinstruction + +import ( + "fmt" + + "gitlab.com/evatix-go/core/constants" +) + +type FromTo struct { + From string `json:"From,omitempty"` + To string `json:"To,omitempty"` +} + +func (it *FromTo) IsNull() bool { + return it == nil +} + +func (it *FromTo) IsFromEmpty() bool { + return it == nil || it.From == "" +} + +func (it *FromTo) IsToEmpty() bool { + return it == nil || it.To == "" +} + +func (it FromTo) String() string { + if it.IsNull() { + return "FromTo null!" + } + + return fmt.Sprintf( + constants.FromToFormat, + it.From, + it.To) +} + +func (it *FromTo) SourceDestination() *SourceDestination { + if it == nil { + return nil + } + + return &SourceDestination{ + Source: it.From, + Destination: it.To, + } +} + +func (it *FromTo) Rename() *Rename { + if it == nil { + return nil + } + + return &Rename{ + Existing: it.From, + New: it.To, + } +} + +func (it *FromTo) Clone() *FromTo { + if it == nil { + return nil + } + + return &FromTo{ + From: it.From, + To: it.To, + } +} diff --git a/coreinstruction/NameList.go b/coreinstruction/NameList.go new file mode 100644 index 0000000000000000000000000000000000000000..91fb8ab18e9670a8560f7ae3e76bf8290ca51f34 --- /dev/null +++ b/coreinstruction/NameList.go @@ -0,0 +1,56 @@ +package coreinstruction + +import ( + "gitlab.com/evatix-go/core/coredata/corejson" + "gitlab.com/evatix-go/core/coredata/corestr" +) + +type NameList struct { + Name string `json:"Name,omitempty"` + List *corestr.SimpleSlice `json:"List,omitempty"` +} + +func (it *NameList) IsNull() bool { + return it == nil +} + +func (it *NameList) IsAnyNull() bool { + return it == nil || it.List == nil +} + +func (it *NameList) IsNameEmpty() bool { + return it == nil || it.Name == "" +} + +func (it *NameList) HasName() bool { + return it != nil && it.Name != "" +} + +func (it NameList) String() string { + if it.IsNull() { + return "" + } + + return corejson. + Serialize. + ToString(it) +} + +func (it *NameList) Clone( + isDeepClone bool, +) *NameList { + if it == nil { + return nil + } + + return &NameList{ + Name: it.Name, + List: it. + List. + ClonePtr(isDeepClone), + } +} + +func (it *NameList) DeepClone() *NameList { + return it.Clone(true) +} diff --git a/coreinstruction/NameListCollection.go b/coreinstruction/NameListCollection.go new file mode 100644 index 0000000000000000000000000000000000000000..31b0b8c1a751205304cbe17f70c57bee7c403bb7 --- /dev/null +++ b/coreinstruction/NameListCollection.go @@ -0,0 +1,41 @@ +package coreinstruction + +import "gitlab.com/evatix-go/core/coredata/corejson" + +type NameListCollection struct { + NameLists []NameList +} + +func (it *NameListCollection) IsNull() bool { + return it == nil +} + +func (it *NameListCollection) IsAnyNull() bool { + return it == nil || it.NameLists == nil +} + +func (it *NameListCollection) IsEmpty() bool { + return it == nil || len(it.NameLists) == 0 +} + +func (it *NameListCollection) HasAnyItem() bool { + return !it.IsEmpty() +} + +func (it *NameListCollection) Length() int { + if it == nil { + return 0 + } + + return len(it.NameLists) +} + +func (it NameListCollection) String() string { + if it.IsNull() { + return "" + } + + return corejson. + Serialize. + ToString(it) +} diff --git a/coreinstruction/NameRequests.go b/coreinstruction/NameRequests.go new file mode 100644 index 0000000000000000000000000000000000000000..6021a9d60eaca5265bcb6c759d8c99fd0fe5ea53 --- /dev/null +++ b/coreinstruction/NameRequests.go @@ -0,0 +1,8 @@ +package coreinstruction + +import "gitlab.com/evatix-go/core/coredata/corestr" + +type NameRequests struct { + Name string `json:"Name,omitempty"` + Requests *corestr.SimpleSlice `json:"Requests,omitempty"` +} diff --git a/coreinstruction/NameRequestsCollection.go b/coreinstruction/NameRequestsCollection.go new file mode 100644 index 0000000000000000000000000000000000000000..b8ec32e31d1ada131f705bd2051196e57fc065b1 --- /dev/null +++ b/coreinstruction/NameRequestsCollection.go @@ -0,0 +1,5 @@ +package coreinstruction + +type NameRequestsCollection struct { + NameRequestsList []NameRequests +} diff --git a/coreinstruction/Rename.go b/coreinstruction/Rename.go new file mode 100644 index 0000000000000000000000000000000000000000..f1dbbcb62acdd77703d464da3dbc69af1bbf5ad0 --- /dev/null +++ b/coreinstruction/Rename.go @@ -0,0 +1,68 @@ +package coreinstruction + +import ( + "fmt" + + "gitlab.com/evatix-go/core/constants" +) + +type Rename struct { + Existing string `json:"Existing,omitempty"` + New string `json:"New,omitempty"` +} + +func (it *Rename) IsNull() bool { + return it == nil +} + +func (it *Rename) IsExistingEmpty() bool { + return it == nil || it.Existing == "" +} + +func (it *Rename) IsNewEmpty() bool { + return it == nil || it.New == "" +} + +func (it Rename) String() string { + if it.IsNull() { + return "Rename null!" + } + + return fmt.Sprintf( + constants.RenameFormat, + it.Existing, + it.New) +} + +func (it *Rename) SourceDestination() *SourceDestination { + if it == nil { + return nil + } + + return &SourceDestination{ + Source: it.Existing, + Destination: it.New, + } +} + +func (it *Rename) FromTo() *FromTo { + if it == nil { + return nil + } + + return &FromTo{ + From: it.Existing, + To: it.New, + } +} + +func (it *Rename) Clone() *Rename { + if it == nil { + return nil + } + + return &Rename{ + Existing: it.Existing, + New: it.New, + } +} diff --git a/coreinstruction/SourceDestination.go b/coreinstruction/SourceDestination.go new file mode 100644 index 0000000000000000000000000000000000000000..8ba4a03774bd01516e666df95a3df190b2094913 --- /dev/null +++ b/coreinstruction/SourceDestination.go @@ -0,0 +1,68 @@ +package coreinstruction + +import ( + "fmt" + + "gitlab.com/evatix-go/core/constants" +) + +type SourceDestination struct { + Source string `json:"Source,omitempty"` + Destination string `json:"Destination,omitempty"` +} + +func (it *SourceDestination) IsNull() bool { + return it == nil +} + +func (it *SourceDestination) IsSourceEmpty() bool { + return it == nil || it.Source == "" +} + +func (it *SourceDestination) IsDestinationEmpty() bool { + return it == nil || it.Destination == "" +} + +func (it SourceDestination) String() string { + if it.IsNull() { + return "SourceDestination null!" + } + + return fmt.Sprintf( + constants.SourceDestinationFormat, + it.Source, + it.Destination) +} + +func (it *SourceDestination) FromTo() *FromTo { + if it == nil { + return nil + } + + return &FromTo{ + From: it.Source, + To: it.Destination, + } +} + +func (it *SourceDestination) Rename() *Rename { + if it == nil { + return nil + } + + return &Rename{ + Existing: it.Source, + New: it.Destination, + } +} + +func (it *SourceDestination) Clone() *SourceDestination { + if it == nil { + return nil + } + + return &SourceDestination{ + Source: it.Source, + Destination: it.Destination, + } +} diff --git a/coreinterface/BasicEnumerGetter.go b/coreinterface/BasicEnumerGetter.go new file mode 100644 index 0000000000000000000000000000000000000000..c7f0e27d1d10cc8b7674f9b0dd32ece4993661f9 --- /dev/null +++ b/coreinterface/BasicEnumerGetter.go @@ -0,0 +1,5 @@ +package coreinterface + +type BasicEnumerGetter interface { + TypeBasicEnum() BasicEnumer +} diff --git a/coreinterface/ByteTypeEnumGetter.go b/coreinterface/ByteTypeEnumGetter.go new file mode 100644 index 0000000000000000000000000000000000000000..e4ab82f21beec95380d42a64d6fc5493d26dd267 --- /dev/null +++ b/coreinterface/ByteTypeEnumGetter.go @@ -0,0 +1,5 @@ +package coreinterface + +type ByteTypeEnumGetter interface { + TypeEnum() BasicByteEnumContractsBinder +} diff --git a/coreinterface/BytesInToSelfDeserializer.go b/coreinterface/BytesInToSelfDeserializer.go new file mode 100644 index 0000000000000000000000000000000000000000..c2148009b216776dea7df377257b98debbc28ab0 --- /dev/null +++ b/coreinterface/BytesInToSelfDeserializer.go @@ -0,0 +1,5 @@ +package coreinterface + +type BytesInToSelfDeserializer interface { + Deserialize(rawBytes []byte) error +} diff --git a/coreinterface/ConditionalLogger.go b/coreinterface/ConditionalLogger.go new file mode 100644 index 0000000000000000000000000000000000000000..4a61ec379db15892af84a7c4c67c9866ad31180c --- /dev/null +++ b/coreinterface/ConditionalLogger.go @@ -0,0 +1,8 @@ +package coreinterface + +type ConditionalLogger interface { + On(isCondition bool) StandardLogger + OnErr(err error) StandardLogger + OnString(message string) StandardLogger + OnBytes(rawBytes []byte) StandardLogger +} diff --git a/coreinterface/DefaultsInjector.go b/coreinterface/DefaultsInjector.go new file mode 100644 index 0000000000000000000000000000000000000000..960f2d62369f2a0970d357de60a6587e70e940e0 --- /dev/null +++ b/coreinterface/DefaultsInjector.go @@ -0,0 +1,5 @@ +package coreinterface + +type DefaultsInjector interface { + InjectDefaults() error +} diff --git a/coreinterface/Deserializer.go b/coreinterface/Deserializer.go index 058af23434c7b03157041f9660764d7805652310..56b98687b44a5f176b694409833cbaf2285402f1 100644 --- a/coreinterface/Deserializer.go +++ b/coreinterface/Deserializer.go @@ -1,5 +1,5 @@ package coreinterface -type Deserializer interface { +type FieldBytesToPointerDeserializer interface { Deserialize(toPtr interface{}) error } diff --git a/coreinterface/Executor.go b/coreinterface/Executor.go new file mode 100644 index 0000000000000000000000000000000000000000..43a41ecab19aa98bfd6be13e5341ca51ed4968ac --- /dev/null +++ b/coreinterface/Executor.go @@ -0,0 +1,5 @@ +package coreinterface + +type Executor interface { + Execute() error +} diff --git a/coreinterface/ExecutorExecutioner.go b/coreinterface/ExecutorExecutioner.go new file mode 100644 index 0000000000000000000000000000000000000000..36201760df75154fc21d35c1a58f805173c0188d --- /dev/null +++ b/coreinterface/ExecutorExecutioner.go @@ -0,0 +1,6 @@ +package coreinterface + +type ExecutorExecutioner interface { + Run(executors ...Executor) error + MustRun(executors ...Executor) +} diff --git a/coreinterface/ExecutorExecutionerContractsBinder.go b/coreinterface/ExecutorExecutionerContractsBinder.go new file mode 100644 index 0000000000000000000000000000000000000000..b707502fe5105b6d4c6dfcee2f62da3e03417be2 --- /dev/null +++ b/coreinterface/ExecutorExecutionerContractsBinder.go @@ -0,0 +1,6 @@ +package coreinterface + +type ExecutorExecutionerContractsBinder interface { + ExecutorExecutioner + AsExecutorExecutionerContractsBinder() ExecutorExecutionerContractsBinder +} diff --git a/coreinterface/MetaGetter.go b/coreinterface/MetaGetter.go new file mode 100644 index 0000000000000000000000000000000000000000..47f19be6d94af88ae397d25c053e0b83ca9ede7a --- /dev/null +++ b/coreinterface/MetaGetter.go @@ -0,0 +1,5 @@ +package coreinterface + +type MetaGetter interface { + Meta() string +} diff --git a/coreinterface/MustBytesInToSelfDeserializer.go b/coreinterface/MustBytesInToSelfDeserializer.go new file mode 100644 index 0000000000000000000000000000000000000000..8f85707475ba7c7d1a74d924e1b0635544343441 --- /dev/null +++ b/coreinterface/MustBytesInToSelfDeserializer.go @@ -0,0 +1,5 @@ +package coreinterface + +type MustBytesInToSelfDeserializer interface { + DeserializeMust(rawBytes []byte) +} diff --git a/coreinterface/MustDefaultsInjector.go b/coreinterface/MustDefaultsInjector.go new file mode 100644 index 0000000000000000000000000000000000000000..5f9ebc9d34d37d962175b52b0f3b3f0327e46808 --- /dev/null +++ b/coreinterface/MustDefaultsInjector.go @@ -0,0 +1,5 @@ +package coreinterface + +type MustDefaultsInjector interface { + MustInjectDefaults() +} diff --git a/coreinterface/MustExecutor.go b/coreinterface/MustExecutor.go new file mode 100644 index 0000000000000000000000000000000000000000..e794d48dc9e0700f2c8587174b6efe07e7d5647d --- /dev/null +++ b/coreinterface/MustExecutor.go @@ -0,0 +1,5 @@ +package coreinterface + +type MustExecutor interface { + MustExecute() +} diff --git a/coreinterface/MustSerializer.go b/coreinterface/MustSerializer.go new file mode 100644 index 0000000000000000000000000000000000000000..a2ec651683e903633a13418d3e5e6932c7fb72c7 --- /dev/null +++ b/coreinterface/MustSerializer.go @@ -0,0 +1,5 @@ +package coreinterface + +type MustSerializer interface { + SerializeMust() []byte +} diff --git a/coreinterface/NameGetter.go b/coreinterface/NameGetter.go new file mode 100644 index 0000000000000000000000000000000000000000..1f2e0b229d17ccdf168f627b27b169fc37abf531 --- /dev/null +++ b/coreinterface/NameGetter.go @@ -0,0 +1,5 @@ +package coreinterface + +type NameGetter interface { + Name() string +} diff --git a/coreinterface/RawPayloadsGetter.go b/coreinterface/RawPayloadsGetter.go new file mode 100644 index 0000000000000000000000000000000000000000..93cdb2480446df2989f0dcf182c776981cd62de7 --- /dev/null +++ b/coreinterface/RawPayloadsGetter.go @@ -0,0 +1,6 @@ +package coreinterface + +type RawPayloadsGetter interface { + RawPayloads() (payloads []byte, err error) + RawPayloadsMust() (payloads []byte) +} diff --git a/coreinterface/SelfBytesSerializerDeserializer.go b/coreinterface/SelfBytesSerializerDeserializer.go new file mode 100644 index 0000000000000000000000000000000000000000..6c659f62b124e4d7f9c17dd3415126f06463c0bf --- /dev/null +++ b/coreinterface/SelfBytesSerializerDeserializer.go @@ -0,0 +1,7 @@ +package coreinterface + +type SelfBytesSerializerDeserializer interface { + Serializer + MustSerializer + FieldBytesToPointerDeserializer +} diff --git a/coreinterface/Serializer.go b/coreinterface/Serializer.go index a58ef7331caa4f96e7cc0bdc8b7e537f13949e48..0726534210e8bab19757357291489343eb9eebf6 100644 --- a/coreinterface/Serializer.go +++ b/coreinterface/Serializer.go @@ -2,5 +2,4 @@ package coreinterface type Serializer interface { Serialize() ([]byte, error) - SerializeMust() []byte } diff --git a/coreinterface/SerializerDeserializer.go b/coreinterface/SerializerDeserializer.go index 00f54922b5eaffdb890522da7979f5d3cc953361..99d8cea06187905b3cc677690f8c8a8905b1e481 100644 --- a/coreinterface/SerializerDeserializer.go +++ b/coreinterface/SerializerDeserializer.go @@ -2,5 +2,6 @@ package coreinterface type SerializerDeserializer interface { Serializer - Deserializer + MustSerializer + BytesInToSelfDeserializer } diff --git a/coreinterface/ServiceExecutor.go b/coreinterface/ServiceExecutor.go new file mode 100644 index 0000000000000000000000000000000000000000..f6059fbcc002f55fa9757abf5956cf0913cb4ec0 --- /dev/null +++ b/coreinterface/ServiceExecutor.go @@ -0,0 +1,11 @@ +package coreinterface + +type ServiceExecutor interface { + StandardExecutor + ServiceNameGetter + DefaultsInjector + MustDefaultsInjector + IsValidChecker + IsInvalidChecker + ValidationErrorGetter +} diff --git a/coreinterface/ServiceExecutorContractsBinder.go b/coreinterface/ServiceExecutorContractsBinder.go new file mode 100644 index 0000000000000000000000000000000000000000..ddeb8d0568eae91a880eee69189104463f8b4935 --- /dev/null +++ b/coreinterface/ServiceExecutorContractsBinder.go @@ -0,0 +1,6 @@ +package coreinterface + +type ServiceExecutorContractsBinder interface { + ServiceExecutor + AsServiceExecutorContractsBinder() ServiceExecutorContractsBinder +} diff --git a/coreinterface/ServiceExecutorDelegator.go b/coreinterface/ServiceExecutorDelegator.go new file mode 100644 index 0000000000000000000000000000000000000000..026fd8ba62039b4748384ff2b4e2b4dc1d3b2b28 --- /dev/null +++ b/coreinterface/ServiceExecutorDelegator.go @@ -0,0 +1,5 @@ +package coreinterface + +type ServiceExecutorDelegator interface { + ServiceExecutor() ServiceExecutor +} diff --git a/coreinterface/ServiceNameGetter.go b/coreinterface/ServiceNameGetter.go new file mode 100644 index 0000000000000000000000000000000000000000..09fca38cbb3c18585b63a63ce979921942723bc3 --- /dev/null +++ b/coreinterface/ServiceNameGetter.go @@ -0,0 +1,5 @@ +package coreinterface + +type ServiceNameGetter interface { + ServiceName() string +} diff --git a/coreinterface/SimpleExecutor.go b/coreinterface/SimpleExecutor.go new file mode 100644 index 0000000000000000000000000000000000000000..5a2104e75909b4fc871a80887ce0cc5047ceea54 --- /dev/null +++ b/coreinterface/SimpleExecutor.go @@ -0,0 +1,8 @@ +package coreinterface + +type SimpleExecutor interface { + NameGetter + TypeNameGetter + Executor + IsApplyFuncBinder +} diff --git a/coreinterface/SimpleExecutorContractsBinder.go b/coreinterface/SimpleExecutorContractsBinder.go new file mode 100644 index 0000000000000000000000000000000000000000..166b6738146d3b789c5d7a42fe0caa42ee4ba0af --- /dev/null +++ b/coreinterface/SimpleExecutorContractsBinder.go @@ -0,0 +1,6 @@ +package coreinterface + +type SimpleExecutorContractsBinder interface { + SimpleExecutor + AsSimpleExecutorContractsBinder() SimpleExecutorContractsBinder +} diff --git a/coreinterface/SimpleExecutorDelegator.go b/coreinterface/SimpleExecutorDelegator.go new file mode 100644 index 0000000000000000000000000000000000000000..cff9cb25656d4dd35a6c0d483a0594a491b6affc --- /dev/null +++ b/coreinterface/SimpleExecutorDelegator.go @@ -0,0 +1,5 @@ +package coreinterface + +type SimpleExecutorDelegator interface { + SimpleExecutor() SimpleExecutor +} diff --git a/coreinterface/StandardExecutor.go b/coreinterface/StandardExecutor.go new file mode 100644 index 0000000000000000000000000000000000000000..9e2a628e59cb1ec5292f103b6f028ea81e50f8af --- /dev/null +++ b/coreinterface/StandardExecutor.go @@ -0,0 +1,14 @@ +package coreinterface + +type StandardExecutor interface { + SimpleExecutor + BasicEnumerGetter + ByteTypeEnumGetter + StandardLoggerGetter + RawPayloadsGetter + MustExecutor +} + +type StandardLoggerGetter interface { + StandardLogger() StandardLogger +} diff --git a/coreinterface/StandardExecutorContractsBinder.go b/coreinterface/StandardExecutorContractsBinder.go new file mode 100644 index 0000000000000000000000000000000000000000..205fa9cb496fb578770b7a493a26daa26ea27c39 --- /dev/null +++ b/coreinterface/StandardExecutorContractsBinder.go @@ -0,0 +1,6 @@ +package coreinterface + +type StandardExecutorContractsBinder interface { + StandardExecutor + AsStandardExecutorContractsBinder() StandardExecutorContractsBinder +} diff --git a/coreinterface/StandardExecutorDelegator.go b/coreinterface/StandardExecutorDelegator.go new file mode 100644 index 0000000000000000000000000000000000000000..a4f2265c920eb7c15d4ad359a4aedffe9250b008 --- /dev/null +++ b/coreinterface/StandardExecutorDelegator.go @@ -0,0 +1,5 @@ +package coreinterface + +type StandardExecutorDelegator interface { + StandardExecutor() StandardExecutor +} diff --git a/coreinterface/StandardExecutorExecutioner.go b/coreinterface/StandardExecutorExecutioner.go new file mode 100644 index 0000000000000000000000000000000000000000..4ba46da252efde0c0dcfd43ae8a215b88d40a43b --- /dev/null +++ b/coreinterface/StandardExecutorExecutioner.go @@ -0,0 +1,6 @@ +package coreinterface + +type StandardExecutorExecutioner interface { + Run(executors ...StandardExecutor) error + MustRun(executors ...StandardExecutor) +} diff --git a/coreinterface/StandardLogger.go b/coreinterface/StandardLogger.go new file mode 100644 index 0000000000000000000000000000000000000000..9bb555d6884def619a213a7c4189322adeee9293 --- /dev/null +++ b/coreinterface/StandardLogger.go @@ -0,0 +1,6 @@ +package coreinterface + +type StandardLogger interface { + LoggerWithFormatLogger + ConditionalLogger +} diff --git a/coreinterface/TypeNamer.go b/coreinterface/TypeNameGetter.go similarity index 57% rename from coreinterface/TypeNamer.go rename to coreinterface/TypeNameGetter.go index b30272cd4094a53ee0584f42438e0261f62c35be..6fcfa0bcadea6afe4f55a31205b594659042cfcf 100644 --- a/coreinterface/TypeNamer.go +++ b/coreinterface/TypeNameGetter.go @@ -1,5 +1,5 @@ package coreinterface -type TypeNamer interface { +type TypeNameGetter interface { TypeName() string } diff --git a/coreinterface/TypeNameWithRangeNamesCsvGetter.go b/coreinterface/TypeNameWithRangeNamesCsvGetter.go index cc300768dcec175a0438a835b7e02482b06d27d3..d09626745fad4e750e04993c391b73e7d949c242 100644 --- a/coreinterface/TypeNameWithRangeNamesCsvGetter.go +++ b/coreinterface/TypeNameWithRangeNamesCsvGetter.go @@ -2,5 +2,5 @@ package coreinterface type TypeNameWithRangeNamesCsvGetter interface { StringRangeNamesCsvGetter - TypeNamer + TypeNameGetter } diff --git a/coreinterface/ValidationErrorGetter.go b/coreinterface/ValidationErrorGetter.go new file mode 100644 index 0000000000000000000000000000000000000000..83d44f3464b437cbf7a5ad8c9981b6238ee6c952 --- /dev/null +++ b/coreinterface/ValidationErrorGetter.go @@ -0,0 +1,5 @@ +package coreinterface + +type ValidationErrorGetter interface { + ValidationError() error +} diff --git a/coreinterface/ValidationMessageGetter.go b/coreinterface/ValidationMessageGetter.go new file mode 100644 index 0000000000000000000000000000000000000000..455f496d5aa937d01d8cbe14beadc557c7fc6c13 --- /dev/null +++ b/coreinterface/ValidationMessageGetter.go @@ -0,0 +1,5 @@ +package coreinterface + +type ValidationMessageGetter interface { + ValidationMessage() string +} diff --git a/coreinterface/enum-contracts.go b/coreinterface/enum-contracts.go index 73d1dbf4ceec13f109241dd14b4afb3bf490e4b3..b8aa6cd8e657dcdb6d2327ba9e1e39df1efb7c2f 100644 --- a/coreinterface/enum-contracts.go +++ b/coreinterface/enum-contracts.go @@ -7,6 +7,8 @@ type BasicEnumer interface { NameValuer ToNumberStringer Stringer + IsValidChecker + IsInvalidChecker corejson.JsonMarshaller } diff --git a/coretests/BaseTestCase.go b/coretests/BaseTestCase.go index 854f5b15429844a167ffd16e2f3eb30818eecda5..a0ccb359584ab3198f3374f3299bc194b00554cb 100644 --- a/coretests/BaseTestCase.go +++ b/coretests/BaseTestCase.go @@ -7,6 +7,7 @@ import ( "gitlab.com/evatix-go/core/constants" "gitlab.com/evatix-go/core/errcore" + "gitlab.com/evatix-go/core/internal/reflectinternal" ) type BaseTestCase struct { @@ -33,11 +34,11 @@ func (it *BaseTestCase) TypesValidationMustPasses(t *testing.T) { func (it *BaseTestCase) TypeValidationError() error { var sliceErr []string - arrangeInputActualType := reflect.TypeOf(it.ArrangeExpectedType) + arrangeInputActualType := reflect.TypeOf(it.ArrangeInput) actualInputActualType := reflect.TypeOf(it.ActualInput) expectedInputActualType := reflect.TypeOf(it.ExpectedInput) - if arrangeInputActualType != it.ArrangeExpectedType { + if reflectinternal.IsNotNull(it.ArrangeInput) && arrangeInputActualType != it.ArrangeExpectedType { sliceErr = append( sliceErr, errcore.Expecting( @@ -46,7 +47,7 @@ func (it *BaseTestCase) TypeValidationError() error { arrangeInputActualType)) } - if actualInputActualType != it.ActualExpectedType { + if reflectinternal.IsNotNull(it.ActualInput) && actualInputActualType != it.ActualExpectedType { sliceErr = append( sliceErr, errcore.Expecting( @@ -55,7 +56,7 @@ func (it *BaseTestCase) TypeValidationError() error { actualInputActualType)) } - if expectedInputActualType != it.ExpectedTypeOfExpected { + if reflectinternal.IsNotNull(it.ExpectedInput) && expectedInputActualType != it.ExpectedTypeOfExpected { sliceErr = append( sliceErr, errcore.Expecting( diff --git a/enums/stringcompareas/Variant.go b/enums/stringcompareas/Variant.go index 9f2a996868d15c572b58b755d978541273a85697..75f903c17cf29468ece9c172235618e2c11c76d7 100644 --- a/enums/stringcompareas/Variant.go +++ b/enums/stringcompareas/Variant.go @@ -28,8 +28,17 @@ const ( NotContains // invert of Anywhere NotAnyChars // invert of AnyChars NotMatchRegex // invert of Regex + Invalid ) +func (it Variant) IsValid() bool { + return it != Invalid +} + +func (it Variant) IsInvalid() bool { + return it == Invalid +} + func (it *Variant) Name() string { return basicEnumImpl.ToEnumString(it.ValueByte()) } @@ -147,8 +156,8 @@ func (it *Variant) RangeNamesCsv() string { return basicEnumImpl.RangeNamesCsv() } -func (it *Variant) AsBasicEnumContractsBinder() coreinterface.BasicEnumContractsBinder { - return it +func (it Variant) AsBasicEnumContractsBinder() coreinterface.BasicEnumContractsBinder { + return &it } func (it *Variant) MaxByte() byte { diff --git a/enums/stringcompareas/vars.go b/enums/stringcompareas/vars.go index 624e3c943d2f7a96e593a2067763c87dabe06642..fb26fb3f481b4072f924db2404b24106a3557b2b 100644 --- a/enums/stringcompareas/vars.go +++ b/enums/stringcompareas/vars.go @@ -20,6 +20,7 @@ var ( NotContains: "NotContains", NotAnyChars: "NotAnyChars", NotMatchRegex: "NotMatchRegex", + Invalid: "Invalid", } basicEnumImpl = enumimpl. diff --git a/enums/versionindexes/Index.go b/enums/versionindexes/Index.go index eb4dfade3d5b42b158621033487629d0906124fa..97300f497c0c144136ab41516c066f0280e732a5 100644 --- a/enums/versionindexes/Index.go +++ b/enums/versionindexes/Index.go @@ -9,12 +9,21 @@ import ( type Index byte const ( - Major Index = iota - Minor Index = 1 - Patch Index = 2 - Build Index = 3 + Major Index = iota + Minor Index = 1 + Patch Index = 2 + Build Index = 3 + Invalid Index = 4 ) +func (it Index) IsValid() bool { + return it != Invalid +} + +func (it Index) IsInvalid() bool { + return it == Invalid +} + func (it *Index) Name() string { return BasicEnumImpl.ToEnumString(it.ValueByte()) } diff --git a/issetter/Value.go b/issetter/Value.go index 339a83808f9a127fb91e30287a37db9b1bf442c3..9957daf1a6b19fad99631c4128279a856295fe39 100644 --- a/issetter/Value.go +++ b/issetter/Value.go @@ -485,6 +485,14 @@ func (it Value) TrueFalseName() string { return trueFalseNames[it] } +func (it Value) OnOffLowercaseName() string { + return lowerCaseOnOffNames[it] +} + +func (it Value) OnOffName() string { + return onOffNames[it] +} + func (it Value) TrueFalseLowercaseName() string { return trueFalseLowerNames[it] } diff --git a/issetter/vars.go b/issetter/vars.go index c6b0c9848af653262056e5c249ab366ad0db46e2..db2d4c6b7caf254d1edc51169f26ab616f152acd 100644 --- a/issetter/vars.go +++ b/issetter/vars.go @@ -41,12 +41,14 @@ var ( "Yes": True, "y": True, "Y": True, + "1": True, "false": False, "False": False, "no": False, "No": False, "n": False, "N": False, + "2": True, "*": Wildcard, "Wildcard": Wildcard, "wildcard": Wildcard, @@ -108,6 +110,24 @@ var ( Wildcard: "*", } + lowerCaseOnOffNames = map[Value]string{ + Uninitialized: "-", + True: "on", + False: "off", + Set: "on", + Unset: "off", + Wildcard: "*", + } + + onOffNames = map[Value]string{ + Uninitialized: "-", + True: "On", + False: "Off", + Set: "On", + Unset: "Off", + Wildcard: "*", + } + trueFalseNames = map[Value]string{ Uninitialized: "-", True: "True", diff --git a/ostype/GetGroup.go b/ostype/GetGroup.go index a0b85830b014974bebe3dce1554e14ca857ba2a7..6a59eec4306f137f070cf9ccdf2915a43f03f94c 100644 --- a/ostype/GetGroup.go +++ b/ostype/GetGroup.go @@ -20,5 +20,5 @@ func GetGroup(rawRuntimeGoos string) Group { return UnixGroup } - return UnknownGroup + return InvalidGroup } diff --git a/ostype/Group.go b/ostype/Group.go index 8a906262934808ea20da823594a97e0dce6963c6..c4cd0f2798900b2e1c37fd47f2a61775b68413b2 100644 --- a/ostype/Group.go +++ b/ostype/Group.go @@ -11,7 +11,7 @@ const ( WindowsGroup Group = iota UnixGroup AndroidGroup - UnknownGroup + InvalidGroup ) func (it Group) Is(another Group) bool { @@ -30,8 +30,8 @@ func (it Group) IsAndroid() bool { return it == AndroidGroup } -func (it Group) IsUnknown() bool { - return it == UnknownGroup +func (it Group) IsInvalidGroup() bool { + return it == InvalidGroup } func (it Group) Byte() byte { @@ -102,6 +102,14 @@ func (it Group) String() string { return basicEnumImplOsGroup.ToEnumString(it.Value()) } +func (it Group) IsValid() bool { + return it != InvalidGroup +} + +func (it Group) IsInvalid() bool { + return it == InvalidGroup +} + func (it *Group) AsBasicEnumContractsBinder() coreinterface.BasicEnumContractsBinder { return it } @@ -110,6 +118,6 @@ func (it *Group) AsJsonContractsBinder() corejson.JsonMarshaller { return it } -func (it *Group) AsBasicByteEnumContractsBinder() coreinterface.BasicByteEnumContractsBinder { - return it +func (it Group) AsBasicByteEnumContractsBinder() coreinterface.BasicByteEnumContractsBinder { + return &it } diff --git a/ostype/Variation.go b/ostype/Variation.go index 8aa726188b8e0a61e5ad6fd8266d84dc8738f802..191a618018daa048492869e728f3e477af6e0d14 100644 --- a/ostype/Variation.go +++ b/ostype/Variation.go @@ -29,6 +29,14 @@ const ( Aix ) +func (it Variation) IsValid() bool { + return it.Value() != 0 +} + +func (it Variation) IsInvalid() bool { + return it.Value() == 0 +} + func (it Variation) IsByte(another byte) bool { return it == Variation(another) } @@ -196,6 +204,6 @@ func (it *Variation) AsJsonContractsBinder() corejson.JsonMarshaller { return it } -func (it *Variation) AsBasicByteEnumContractsBinder() coreinterface.BasicByteEnumContractsBinder { - return it +func (it Variation) AsBasicByteEnumContractsBinder() coreinterface.BasicByteEnumContractsBinder { + return &it } diff --git a/ostype/vars.go b/ostype/vars.go index 7249c2c5997bce73e083ed3e21acf7cc1620c4a6..609f4b10af3bb8e9fb62afa374fa08a202379053 100644 --- a/ostype/vars.go +++ b/ostype/vars.go @@ -17,7 +17,7 @@ var ( "UnixGroup", "AndroidGroup", "JavaScriptGroup", - "UnknownGroup", + "InvalidGroup", } basicEnumImplOsType = enumimpl.NewBasicByteUsingIndexedSlice( diff --git a/reqtype/Min.go b/reqtype/Min.go index 7eea7aabf07baef80c9239436735fa1644472941..ccabccd2df64e8b5d284d1a549b15ee817542c1b 100644 --- a/reqtype/Min.go +++ b/reqtype/Min.go @@ -1,5 +1,5 @@ package reqtype func Min() Request { - return Uninitialized + return Invalid } diff --git a/reqtype/Request.go b/reqtype/Request.go index 835f06b18fb327e22b5b726c6b187e49d90f0c32..81096b9a9db6360350db66ea21f18c8c0ceb6479 100644 --- a/reqtype/Request.go +++ b/reqtype/Request.go @@ -14,7 +14,7 @@ type Request byte // https://www.restapitutorial.com/lessons/httpmethods.html const ( - Uninitialized Request = iota + Invalid Request = iota Create Read Update @@ -68,12 +68,20 @@ const ( DynamicAction ) +func (it Request) IsValid() bool { + return it != Invalid +} + +func (it Request) IsInvalid() bool { + return it == Invalid +} + func (it Request) NameValue() string { return BasicEnumImpl.NameWithValue(it) } func (it Request) IsUninitialized() bool { - return it == Uninitialized + return it == Invalid } func (it Request) RangeNamesCsv() string { @@ -585,7 +593,7 @@ func (it Request) ToPtr() *Request { func (it *Request) ToSimple() Request { if it == nil { - return Uninitialized + return Invalid } return *it @@ -595,14 +603,14 @@ func (it Request) MarshalJSON() ([]byte, error) { return BasicEnumImpl.ToEnumJsonBytes(it.Value()), nil } -func (it *Request) AsBasicEnumContractsBinder() coreinterface.BasicEnumContractsBinder { - return it +func (it Request) AsBasicEnumContractsBinder() coreinterface.BasicEnumContractsBinder { + return &it } func (it *Request) AsJsonMarshaller() corejson.JsonMarshaller { return it } -func (it *Request) AsBasicByteEnumContractsBinder() coreinterface.BasicByteEnumContractsBinder { - return it +func (it Request) AsBasicByteEnumContractsBinder() coreinterface.BasicByteEnumContractsBinder { + return &it } diff --git a/reqtype/vars.go b/reqtype/vars.go index 7ab9812671fdb2505e8b879a277bd91c6597f9b7..2be2414be2c15ecd8a91bfd2b1eb7b3cf84644ad 100644 --- a/reqtype/vars.go +++ b/reqtype/vars.go @@ -7,7 +7,7 @@ import ( var ( Ranges = [...]string{ - Uninitialized: "Uninitialized", + Invalid: "Invalid", Create: "Create", Read: "Read", Update: "Update", @@ -62,7 +62,7 @@ var ( } RangesMap = map[string]Request{ - "Uninitialized": Uninitialized, + "Invalid": Invalid, "Create": Create, "Read": Read, "Update": Update, @@ -117,6 +117,6 @@ var ( } BasicEnumImpl = enumimpl.NewBasicByteUsingIndexedSlice( - reflectinternal.TypeName(Uninitialized), + reflectinternal.TypeName(Invalid), Ranges[:]) )