import
java.util.Collection;
import
java.util.LinkedList;
import
java.util.List;
import
javax.management.MalformedObjectNameException;
import
javax.management.ObjectName;
import
javax.management.relation.Role;
import
javax.management.relation.RoleList;
public
class
GFG {
private
RoleList rList;
public
GFG() { rList =
new
RoleList(); }
public
GFG(
int
inicapacity)
{
rList =
new
RoleList(inicapacity);
}
public
GFG(List<Role> list)
{
rList =
new
RoleList(list);
}
public
void
add(
int
index, Object element)
{
rList.add(index, element);
}
public
void
add(
int
index, Role role)
{
rList.add(index, role);
}
public
boolean
add(Object o)
{
return
rList.add(o);
}
public
void
add(Role role)
{
rList.add(role);
}
public
boolean
addAll(Collection<?> c)
{
return
rList.addAll(c);
}
public
boolean
addAll(
int
index, Collection<?> c)
{
return
rList.addAll(index, c);
}
public
boolean
addAll(
int
index, RoleList roleList)
{
return
this
.rList.addAll(index, rList);
}
public
boolean
addAll(RoleList rList)
{
return
rList.addAll(rList);
}
public
List<Role> asList()
{
return
rList.asList();
}
public
Object set(
int
index, Object element)
{
return
rList.set(index, element);
}
public
void
set(
int
index, Role role)
{
rList.set(index, role);
}
public
static
void
main(String[] arg)
throws
MalformedObjectNameException
{
GFG rList =
new
GFG();
List<ObjectName> rlist1
=
new
LinkedList<ObjectName>();
rlist1.add(
new
ObjectName(
"domain1_"
,
"key1_"
,
"value1_"
));
rlist1.add(
new
ObjectName(
"domain2_"
,
"key2_"
,
"value3_"
));
rList.add(
0
,
new
Role(
"1_rolename"
, rlist1));
List<ObjectName> rList2
=
new
LinkedList<ObjectName>();
rList2.add(
new
ObjectName(
"domain3_"
,
"key3_"
,
"value3_"
));
rList2.add(
new
ObjectName(
"domain4_"
,
"key4_"
,
"value4_"
));
rList.add(
1
,
new
Role(
"2_rolename"
, rList2));
List<Role> list = rList.asList();
int
index =
0
;
while
(index < list.size()) {
System.out.println(list.get(index++) +
" "
);
}
System.out.println();
}
}