From 9286cce884615039a1bb342848a5de7ddfcd0a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Sun, 1 Sep 2024 17:06:21 +0200 Subject: [PATCH] capability: normal go formatting for enums --- capability/policy/match.go | 22 +++++++++---------- capability/policy/policy.go | 44 ++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/capability/policy/match.go b/capability/policy/match.go index b665aa1..46f525e 100644 --- a/capability/policy/match.go +++ b/capability/policy/match.go @@ -24,7 +24,7 @@ func Match(policy Policy, node ipld.Node) bool { func matchStatement(statement Statement, node ipld.Node) bool { switch statement.Kind() { - case Kind_Equal: + case KindEqual: if s, ok := statement.(EqualityStatement); ok { one, _, err := selector.Select(s.Selector(), node) if err != nil || one == nil { @@ -32,7 +32,7 @@ func matchStatement(statement Statement, node ipld.Node) bool { } return datamodel.DeepEqual(s.Value(), one) } - case Kind_GreaterThan: + case KindGreaterThan: if s, ok := statement.(InequalityStatement); ok { one, _, err := selector.Select(s.Selector(), node) if err != nil || one == nil { @@ -40,7 +40,7 @@ func matchStatement(statement Statement, node ipld.Node) bool { } return isOrdered(s.Value(), one, gt) } - case Kind_GreaterThanOrEqual: + case KindGreaterThanOrEqual: if s, ok := statement.(InequalityStatement); ok { one, _, err := selector.Select(s.Selector(), node) if err != nil || one == nil { @@ -48,7 +48,7 @@ func matchStatement(statement Statement, node ipld.Node) bool { } return isOrdered(s.Value(), one, gte) } - case Kind_LessThan: + case KindLessThan: if s, ok := statement.(InequalityStatement); ok { one, _, err := selector.Select(s.Selector(), node) if err != nil || one == nil { @@ -56,7 +56,7 @@ func matchStatement(statement Statement, node ipld.Node) bool { } return isOrdered(s.Value(), one, lt) } - case Kind_LessThanOrEqual: + case KindLessThanOrEqual: if s, ok := statement.(InequalityStatement); ok { one, _, err := selector.Select(s.Selector(), node) if err != nil || one == nil { @@ -64,11 +64,11 @@ func matchStatement(statement Statement, node ipld.Node) bool { } return isOrdered(s.Value(), one, lte) } - case Kind_Not: + case KindNot: if s, ok := statement.(NegationStatement); ok { return !matchStatement(s.Value(), node) } - case Kind_And: + case KindAnd: if s, ok := statement.(ConjunctionStatement); ok { for _, cs := range s.Value() { r := matchStatement(cs, node) @@ -78,7 +78,7 @@ func matchStatement(statement Statement, node ipld.Node) bool { } return true } - case Kind_Or: + case KindOr: if s, ok := statement.(DisjunctionStatement); ok { if len(s.Value()) == 0 { return true @@ -91,7 +91,7 @@ func matchStatement(statement Statement, node ipld.Node) bool { } return false } - case Kind_Like: + case KindLike: if s, ok := statement.(WildcardStatement); ok { one, _, err := selector.Select(s.Selector(), node) if err != nil || one == nil { @@ -103,7 +103,7 @@ func matchStatement(statement Statement, node ipld.Node) bool { } return s.Value().Match(v) } - case Kind_All: + case KindAll: if s, ok := statement.(QuantifierStatement); ok { _, many, err := selector.Select(s.Selector(), node) if err != nil || many == nil { @@ -117,7 +117,7 @@ func matchStatement(statement Statement, node ipld.Node) bool { } return true } - case Kind_Any: + case KindAny: if s, ok := statement.(QuantifierStatement); ok { _, many, err := selector.Select(s.Selector(), node) if err != nil || many == nil { diff --git a/capability/policy/policy.go b/capability/policy/policy.go index be947f0..1825407 100644 --- a/capability/policy/policy.go +++ b/capability/policy/policy.go @@ -10,17 +10,17 @@ import ( ) const ( - Kind_Equal = "==" - Kind_GreaterThan = ">" - Kind_GreaterThanOrEqual = ">=" - Kind_LessThan = "<" - Kind_LessThanOrEqual = "<=" - Kind_Not = "not" - Kind_And = "and" - Kind_Or = "or" - Kind_Like = "like" - Kind_All = "all" - Kind_Any = "any" + KindEqual = "==" + KindGreaterThan = ">" + KindGreaterThanOrEqual = ">=" + KindLessThan = "<" + KindLessThanOrEqual = "<=" + KindNot = "not" + KindAnd = "and" + KindOr = "or" + KindLike = "like" + KindAll = "all" + KindAny = "any" ) type Policy = []Statement @@ -91,23 +91,23 @@ func (e equality) Selector() selector.Selector { } func Equal(selector selector.Selector, value ipld.Node) EqualityStatement { - return equality{Kind_Equal, selector, value} + return equality{KindEqual, selector, value} } func GreaterThan(selector selector.Selector, value ipld.Node) InequalityStatement { - return equality{Kind_GreaterThan, selector, value} + return equality{KindGreaterThan, selector, value} } func GreaterThanOrEqual(selector selector.Selector, value ipld.Node) InequalityStatement { - return equality{Kind_GreaterThanOrEqual, selector, value} + return equality{KindGreaterThanOrEqual, selector, value} } func LessThan(selector selector.Selector, value ipld.Node) InequalityStatement { - return equality{Kind_LessThan, selector, value} + return equality{KindLessThan, selector, value} } func LessThanOrEqual(selector selector.Selector, value ipld.Node) InequalityStatement { - return equality{Kind_LessThanOrEqual, selector, value} + return equality{KindLessThanOrEqual, selector, value} } type negation struct { @@ -115,7 +115,7 @@ type negation struct { } func (n negation) Kind() string { - return Kind_Not + return KindNot } func (n negation) Value() Statement { @@ -131,7 +131,7 @@ type conjunction struct { } func (n conjunction) Kind() string { - return Kind_And + return KindAnd } func (n conjunction) Value() []Statement { @@ -147,7 +147,7 @@ type disjunction struct { } func (n disjunction) Kind() string { - return Kind_Or + return KindOr } func (n disjunction) Value() []Statement { @@ -164,7 +164,7 @@ type wildcard struct { } func (n wildcard) Kind() string { - return Kind_Like + return KindLike } func (n wildcard) Selector() selector.Selector { @@ -198,9 +198,9 @@ func (n quantifier) Value() Policy { } func All(selector selector.Selector, policy ...Statement) QuantifierStatement { - return quantifier{Kind_All, selector, policy} + return quantifier{KindAll, selector, policy} } func Any(selector selector.Selector, policy ...Statement) QuantifierStatement { - return quantifier{Kind_Any, selector, policy} + return quantifier{KindAny, selector, policy} }