如何从流口水的地图中获取值
how to get values from map in drools
我正在地图中插入一组键和值,并尝试在 drools 中获取这些地图值。我需要知道如何从 Drools
中的地图获取值
在Java
Map<String,String>mapTest = new HashMap<String,String>();
mapTest.put("name","John Doe");
mapTest.put("id","123");
流口水
rule "when id equals 1000"
when
$obj1 :Map(this["id"] == "1000");
then
System.out.println("ID is equal to 1000" + $obj1);
//this $obj1 prints map values in console
//but i need to print only value of name (Print "John Doe")
end
您可以使用地图方法 get
访问单个地图条目。右侧代码("then part" 只是 Java 代码(有一些扩展)。
System.out.println("ID is equal to 1000 " + $obj1.get( "name") );
我正在地图中插入一组键和值,并尝试在 drools 中获取这些地图值。我需要知道如何从 Drools
中的地图获取值在Java
Map<String,String>mapTest = new HashMap<String,String>();
mapTest.put("name","John Doe");
mapTest.put("id","123");
流口水
rule "when id equals 1000"
when
$obj1 :Map(this["id"] == "1000");
then
System.out.println("ID is equal to 1000" + $obj1);
//this $obj1 prints map values in console
//but i need to print only value of name (Print "John Doe")
end
您可以使用地图方法 get
访问单个地图条目。右侧代码("then part" 只是 Java 代码(有一些扩展)。
System.out.println("ID is equal to 1000 " + $obj1.get( "name") );