MCPcopy Index your code
hub / github.com/apache/dubbo-python2 / Object

Class Object

dubbo/codec/encoder.py:20–58  ·  view source on GitHub ↗

创建一个Java对象

Source from the content-addressed store, hash-verified

18
19
20class Object(object):
21 """
22 创建一个Java对象
23 """
24
25 def __init__(self, path, values=None):
26 """
27 :param path: Java对象的路径,例如:java.lang.Object
28 :param values: 可以在创建对象时就进行赋值
29 """
30 if not isinstance(path, (str, unicode)):
31 raise ValueError('Object path {} should be string type.'.format(path))
32 self.__path = path
33 if not isinstance(values, dict):
34 values = {}
35 self.__values = values
36
37 def __getitem__(self, key):
38 return self.__values[key]
39
40 def __setitem__(self, key, value):
41 if not isinstance(key, (str, unicode)):
42 raise ValueError('Object key {} should be string type.'.format(key))
43 self.__values[key] = value
44
45 def __delitem__(self, key):
46 del self.__values[key]
47
48 def __repr__(self):
49 return '<java object {} at {} with {}>'.format(self.__path, hex(id(self)), self.__values)
50
51 def __contains__(self, key):
52 return key in self.__values
53
54 def keys(self):
55 return self.__values.keys()
56
57 def get_path(self):
58 return self.__path
59
60
61class Request(object):

Callers 6

test_auto_ruleMethod · 0.90
test_objectMethod · 0.90
test_arrayMethod · 0.90
test_pcMethod · 0.90
test_pc_es_centerMethod · 0.90
test_run_defaultMethod · 0.90

Calls

no outgoing calls

Tested by 6

test_auto_ruleMethod · 0.72
test_objectMethod · 0.72
test_arrayMethod · 0.72
test_pcMethod · 0.72
test_pc_es_centerMethod · 0.72
test_run_defaultMethod · 0.72