apache-ignite
62 строки · 2.1 Кб
1# Licensed to the Apache Software Foundation (ASF) under one or more
2# contributor license agreements. See the NOTICE file distributed with
3# this work for additional information regarding copyright ownership.
4# The ASF licenses this file to You under the Apache License, Version 2.0
5# (the "License"); you may not use this file except in compliance with
6# the License. You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License
15
16class Bean:
17"""
18Helper class to store bean class name, optional constructor parameters and optional set of
19name/value pairs for properties.
20
21Serves as a parameter for the 'bean' jinja2 template macro used to generate lists of beans in the XML
22ignite node configuration (see the ignitetest/services/utils/templates/misc_macro.j2::bean).
23
24Hashable to be stored in a set.
25"""
26def __init__(self, class_name, bean_id="", constructor_args=None, **kwargs):
27"""
28:param class_name: bean class name
29:param bean_id: optional bean id
30:param constructor_args: optional list of constructor parameters
31:param kwargs: properties name / value pairs
32"""
33if constructor_args is None:
34self.constructor_args = []
35else:
36self.constructor_args = constructor_args
37
38self.id = bean_id
39self.class_name = class_name
40self.properties = kwargs
41
42def __eq__(self, other):
43return other is not None and self.class_name == other.class_name
44
45def __hash__(self):
46return hash(self.class_name)
47
48def __repr__(self):
49return self.class_name
50
51class_name: str
52properties: {}
53
54
55class BeanRef:
56"""
57Helper class to represent property which is a bean reference.
58"""
59def __init__(self, ref):
60self.ref = ref
61
62ref: str
63