forked from hazelcast/hazelcast-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class_definition.go
113 lines (94 loc) · 2.64 KB
/
class_definition.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package classdef
import "github.com/ahmetmircik/hazelcast-go-client/serialization"
type ClassDefinitionImpl struct {
factoryID int32
classID int32
version int32
fields map[string]serialization.FieldDefinition
}
func NewClassDefinitionImpl(factoryID int32, classID int32, version int32) *ClassDefinitionImpl {
return &ClassDefinitionImpl{factoryID, classID, version, make(map[string]serialization.FieldDefinition)}
}
func (cd *ClassDefinitionImpl) FactoryID() int32 {
return cd.factoryID
}
func (cd *ClassDefinitionImpl) ClassID() int32 {
return cd.classID
}
func (cd *ClassDefinitionImpl) Version() int32 {
return cd.version
}
func (cd *ClassDefinitionImpl) Field(name string) serialization.FieldDefinition {
return cd.fields[name]
}
func (cd *ClassDefinitionImpl) FieldCount() int {
return len(cd.fields)
}
func (cd *ClassDefinitionImpl) AddFieldDefinition(definition serialization.FieldDefinition) {
cd.fields[definition.Name()] = definition
}
type FieldDefinitionImpl struct {
index int32
fieldName string
fieldType int32
factoryID int32
classID int32
version int32
}
func NewFieldDefinitionImpl(index int32, fieldName string, fieldType int32, factoryID int32,
classID int32, version int32) serialization.FieldDefinition {
return &FieldDefinitionImpl{index, fieldName, fieldType, factoryID, classID, version}
}
func (fd *FieldDefinitionImpl) Type() int32 {
return fd.fieldType
}
func (fd *FieldDefinitionImpl) Name() string {
return fd.fieldName
}
func (fd *FieldDefinitionImpl) Index() int32 {
return fd.index
}
func (fd *FieldDefinitionImpl) ClassID() int32 {
return fd.classID
}
func (fd *FieldDefinitionImpl) FactoryID() int32 {
return fd.factoryID
}
func (fd *FieldDefinitionImpl) Version() int32 {
return fd.version
}
const (
TypePortable = iota
TypeByte
TypeBool
TypeUint16
TypeInt16
TypeInt32
TypeInt64
TypeFloat32
TypeFloat64
TypeUTF
TypePortableArray
TypeByteArray
TypeBoolArray
TypeUint16Array
TypeInt16Array
TypeInt32Array
TypeInt64Array
TypeFloat32Array
TypeFloat64Array
TypeUTFArray
)