blob: ef113f6897117a9af1f2f9e215b383316124226e (
plain)
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
|
// **********************************************************************
//
// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
package Ice;
/**
* Handles callbacks for an optional object parameter.
**/
public class OptionalObject implements ReadObjectCallback, IceInternal.Patcher
{
/**
* Instantiates the class with the given optional.
*
* @param opt The target optional.
* @param cls The formal type required for the unmarshaled object.
* @param type The Slice type ID corresponding to the formal type.
**/
@SuppressWarnings("rawtypes")
public
OptionalObject(Optional opt, Class<?> cls, String type)
{
this.opt = opt;
this.cls = cls;
this.type = type;
}
/**
* Sets the Ice object of the optional to the passed instance.
*
* @param v The new object for the optional.
**/
@SuppressWarnings("unchecked")
@Override
public void
patch(Ice.Object v)
{
if(v == null || cls.isInstance(v))
{
//
// The line below would normally cause an "unchecked cast" warning.
//
opt.set(v);
}
else
{
IceInternal.Ex.throwUOE(type, v);
}
}
/**
* Returns the Slice type ID of the most-derived Slice type supported
* by this instance.
*
* @return The Slice type ID.
**/
@Override
public String
type()
{
return this.type;
}
/**
* Sets the Ice object of the optional to the passed instance.
*
* @param obj The new object for the optional.
**/
@Override
public void
invoke(Ice.Object obj)
{
patch(obj);
}
/**
* The optional object.
**/
@SuppressWarnings("rawtypes")
public Optional opt;
/**
* The formal type of the target class.
**/
public Class<?> cls;
/**
* The Slice type ID of the target class.
**/
public String type;
}
|