本文整理汇总了Java中org.eclipse.leshan.core.model.ResourceModel.Type.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java Type.valueOf方法的具体用法?Java Type.valueOf怎么用?Java Type.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.leshan.core.model.ResourceModel.Type
的用法示例。
在下文中一共展示了Type.valueOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import org.eclipse.leshan.core.model.ResourceModel.Type; //导入方法依赖的package包/类
@Override
public ResourceModel deserialize(JsonElement json, java.lang.reflect.Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
if (json == null)
return null;
if (!json.isJsonObject())
return null;
JsonObject jsonObject = json.getAsJsonObject();
if (!jsonObject.has("id"))
return null;
int id = jsonObject.get("id").getAsInt();
String name = jsonObject.get("name").getAsString();
Operations operations = Operations.valueOf(jsonObject.get("operations").getAsString());
String instancetype = jsonObject.get("instancetype").getAsString();
boolean mandatory = jsonObject.get("mandatory").getAsBoolean();
Type type = Type.valueOf(jsonObject.get("type").getAsString().toUpperCase());
String range = jsonObject.get("range").getAsString();
String units = jsonObject.get("units").getAsString();
String description = jsonObject.get("description").getAsString();
return new ResourceModel(id, name, operations, "multiple".equals(instancetype), mandatory, type, range, units,
description);
}
示例2: deserialize
import org.eclipse.leshan.core.model.ResourceModel.Type; //导入方法依赖的package包/类
@Override
public ResourceModel deserialize(JsonObject o) {
if (o == null)
return null;
if (!o.isObject())
return null;
int id = o.getInt("id", -1);
if (id < 0)
return null;
String name = o.getString("name", null);
Operations operations = Operations.valueOf(o.getString("operations", null));
String instancetype = o.getString("instancetype", null);
boolean mandatory = o.getBoolean("mandatory", false);
Type type = Type.valueOf(o.getString("type", "").toUpperCase());
String range = o.getString("range", null);
String units = o.getString("units", null);
String description = o.getString("description", null);
return new ResourceModel(id, name, operations, "multiple".equals(instancetype), mandatory, type, range, units,
description);
}