Documentation ¶
Overview ¶
Package pattern provides functionality for filtering and matching models.
Index ¶
- Constants
- Variables
- func GetAlarmInfoName(f string) string
- func GetBoolValue(v interface{}) (bool, error)
- func GetEntityComponentInfoName(f string) string
- func GetEntityInfoName(f string) string
- func GetEventExtraInfoName(f string) string
- func GetIntValue(v interface{}) (int64, error)
- func GetStringArrayValue(v interface{}) ([]string, error)
- func GetStringValue(v interface{}) (string, error)
- func IsForbiddenAlarmField(condition FieldCondition, forbiddenFieldsMap map[string]bool, ...) bool
- func IsForbiddenEntityField(condition FieldCondition, forbiddenFieldsMap map[string]bool) bool
- type Alarm
- type Condition
- func NewBoolCondition(t string, b bool) Condition
- func NewDurationCondition(t string, d datetime.DurationWithUnit) (Condition, error)
- func NewIntCondition(t string, i int64) Condition
- func NewRegexpCondition(t, s string) (Condition, error)
- func NewStringArrayCondition(t string, a []string) Condition
- func NewStringCondition(t, s string) Condition
- func NewTimeIntervalCondition(t string, from, to int64) Condition
- func (c *Condition) BoolInArrayToMongoQuery(arrayField, arrayItemField string) (bson.M, error)
- func (c *Condition) BoolToMongoQuery(f string) (bson.M, error)
- func (c *Condition) BoolToSql(f string) (string, error)
- func (c *Condition) BoolToSqlJson(field, key string) (string, error)
- func (c *Condition) DurationToMongoQuery(f string) (bson.M, error)
- func (c *Condition) DurationToSql(f string) (string, error)
- func (c *Condition) GetRegexp() utils.RegexExpression
- func (c *Condition) GetValueStr() *string
- func (c *Condition) GetValueStrArray() []string
- func (c *Condition) IntInArrayToMongoQuery(arrayField, arrayItemField string, checkExists bool) (bson.M, error)
- func (c *Condition) IntToMongoQuery(f string, checkExists bool) (bson.M, error)
- func (c *Condition) IntToSql(f string) (string, error)
- func (c *Condition) IntToSqlJson(field, key string) (string, error)
- func (c *Condition) MatchBool(value bool) (bool, error)
- func (c *Condition) MatchDuration(value int64) (bool, error)
- func (c *Condition) MatchInt(value int64) (bool, error)
- func (c *Condition) MatchRef(value interface{}) (bool, error)
- func (c *Condition) MatchString(value string) (bool, error)
- func (c *Condition) MatchStringArray(value []string) (bool, error)
- func (c *Condition) MatchStringWithRegexpMatches(value string) (bool, RegexMatches, error)
- func (c *Condition) MatchTime(value time.Time) (bool, error)
- func (c *Condition) RefInArrayToMongoQuery(arrayField, arrayItemField string) (bson.M, error)
- func (c *Condition) RefToMongoQuery(f string) (bson.M, error)
- func (c *Condition) RefToSqlJson(field, key string) (string, error)
- func (c *Condition) StringArrayInArrayToMongoQuery(arrayField, arrayItemField string, checkExists bool) (bson.M, error)
- func (c *Condition) StringArrayToMongoQuery(f string, checkExists bool) (bson.M, error)
- func (c *Condition) StringArrayToSqlJson(field, key string) (string, error)
- func (c *Condition) StringInArrayToMongoQuery(arrayField, arrayItemField string, checkExists bool) (bson.M, error)
- func (c *Condition) StringToMongoQuery(f string, checkExists bool) (bson.M, error)
- func (c *Condition) StringToSql(f string) (string, error)
- func (c *Condition) StringToSqlJson(field, key string) (string, error)
- func (c *Condition) TimeToMongoQuery(f string) (bson.M, error)
- func (c *Condition) UnmarshalBSONValue(_ bsontype.Type, b []byte) error
- func (c *Condition) UnmarshalJSON(b []byte) error
- type Entity
- type Event
- type FieldCondition
- type PbehaviorInfo
- type RegexMatches
- type WeatherServicePattern
Constants ¶
View Source
const ( ConditionEqual = "eq" ConditionNotEqual = "neq" ConditionGT = "gt" ConditionLT = "lt" ConditionRegexp = "regexp" ConditionContain = "contain" ConditionNotContain = "not_contain" ConditionBeginWith = "begin_with" ConditionNotBeginWith = "not_begin_with" ConditionEndWith = "end_with" ConditionNotEndWith = "not_end_with" ConditionHasEvery = "has_every" ConditionHasOneOf = "has_one_of" ConditionHasNot = "has_not" ConditionIsEmpty = "is_empty" ConditionExist = "exist" ConditionTimeRelative = "relative_time" ConditionTimeAbsolute = "absolute_time" ConditionIsOneOf = "is_one_of" ConditionIsNotOneOf = "is_not_one_of" )
View Source
const ( FieldTypeString = "string" FieldTypeInt = "int" FieldTypeBool = "bool" FieldTypeStringArray = "string_array" )
Variables ¶
Functions ¶
func IsForbiddenAlarmField ¶
func IsForbiddenEntityField ¶
func IsForbiddenEntityField(condition FieldCondition, forbiddenFieldsMap map[string]bool) bool
Types ¶
type Alarm ¶
type Alarm [][]FieldCondition
type Condition ¶
type Condition struct { Type string `json:"type" bson:"type"` Value interface{} `json:"value" bson:"value"` // contains filtered or unexported fields }
Condition represents an expression to decide if a value fits.
func NewDurationCondition ¶
func NewDurationCondition(t string, d datetime.DurationWithUnit) (Condition, error)
func (*Condition) BoolInArrayToMongoQuery ¶
func (*Condition) BoolToSqlJson ¶
func (*Condition) DurationToMongoQuery ¶
func (*Condition) GetRegexp ¶
func (c *Condition) GetRegexp() utils.RegexExpression
func (*Condition) IntInArrayToMongoQuery ¶
func (*Condition) IntToMongoQuery ¶
func (*Condition) IntToSqlJson ¶
func (*Condition) MatchStringArray ¶
func (*Condition) MatchStringWithRegexpMatches ¶
func (c *Condition) MatchStringWithRegexpMatches(value string) (bool, RegexMatches, error)
func (*Condition) RefInArrayToMongoQuery ¶
func (*Condition) RefToSqlJson ¶
func (*Condition) StringArrayInArrayToMongoQuery ¶
func (*Condition) StringArrayToMongoQuery ¶
func (*Condition) StringArrayToSqlJson ¶
func (*Condition) StringInArrayToMongoQuery ¶
func (*Condition) StringToMongoQuery ¶
func (*Condition) StringToSqlJson ¶
func (*Condition) UnmarshalBSONValue ¶
type Entity ¶
type Entity [][]FieldCondition
type Event ¶
type Event [][]FieldCondition
type FieldCondition ¶
type FieldCondition struct { Field string `json:"field" bson:"field"` // FieldType is only defined for custom fields, ex: infos. FieldType string `json:"field_type,omitempty" bson:"field_type,omitempty"` Condition Condition `json:"cond" bson:"cond"` }
FieldCondition represents a condition for a specific field.
func (*FieldCondition) MatchInfoCondition ¶
func (c *FieldCondition) MatchInfoCondition(infoVal any, infoExists bool) (bool, error)
MatchInfoCondition is a helper function to match FieldCondition when it's used to match various infos fields.
func (*FieldCondition) ValidateInfoCondition ¶
func (c *FieldCondition) ValidateInfoCondition() bool
ValidateInfoCondition is a helper function to validate FieldCondition when it's used to match various infos fields.
type PbehaviorInfo ¶
type PbehaviorInfo [][]FieldCondition
type RegexMatches ¶
RegexMatches is a type that contains the values of the sub-expressions of a regular expression.
type WeatherServicePattern ¶
type WeatherServicePattern [][]FieldCondition
func (WeatherServicePattern) HasField ¶
func (p WeatherServicePattern) HasField(field string) bool
Source Files ¶
Click to show internal directories.
Click to hide internal directories.