本文整理匯總了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);
}