本文整理汇总了Java中org.jboss.dmr.ModelType.OBJECT属性的典型用法代码示例。如果您正苦于以下问题:Java ModelType.OBJECT属性的具体用法?Java ModelType.OBJECT怎么用?Java ModelType.OBJECT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.jboss.dmr.ModelType
的用法示例。
在下文中一共展示了ModelType.OBJECT属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOperationDefinition
@Override
public OperationDefinition getOperationDefinition() {
final AttributeDefinition[] parameters = new AttributeDefinition[] {OperationsConstants.VDB_NAME, OperationsConstants.VDB_VERSION};
final ResourceDescriptionResolver resolver = new TeiidResourceDescriptionResolver(name());
return new OperationDefinition(name(), OperationEntry.EntryType.PUBLIC, EnumSet.noneOf(OperationEntry.Flag.class), ModelType.OBJECT, null, true, null, null, parameters) {
@Override
public DescriptionProvider getDescriptionProvider() {
return new DefaultOperationDescriptionProvider(name(), resolver, resolver, ModelType.OBJECT, ModelType.OBJECT, null, null, this.parameters) {
@Override
protected ModelNode getReplyValueTypeDescription(ResourceDescriptionResolver descriptionResolver, Locale locale, ResourceBundle bundle) {
return VDBMetadataMapper.INSTANCE.describe( new ModelNode());
}
};
}
};
}
示例2: resolveValueType
public static String resolveValueType(ModelNode value) {
String templatedType = "?";
final ModelNode valueTypeNode = value.get("value-type");
if (valueTypeNode.getType() == ModelType.OBJECT) {
templatedType = "java.util.Map";
} else {
final ModelType type = valueTypeNode.asType();
if (type == ModelType.STRING) {
templatedType = "String";
} else if ( type == ModelType.PROPERTY ) {
templatedType = Property.class.getName();
}
}
return templatedType;
}
示例3: resolveModelType
public static ModelType resolveModelType(Class<?> javaType) {
ModelType type = null;
if(String.class.equals(javaType))
type = ModelType.STRING;
else if(Enum.class.isAssignableFrom(javaType))
type = ModelType.STRING;
else if(Integer.class.equals(javaType))
type = ModelType.INT;
else if(Long.class.equals(javaType))
type = ModelType.LONG;
else if(Boolean.class.equals(javaType))
type = ModelType.BOOLEAN;
else if(Double.class.equals(javaType))
type = ModelType.DOUBLE;
else if(BigDecimal.class.equals(javaType))
type = ModelType.BIG_DECIMAL;
else if(List.class.isAssignableFrom(javaType))
type = ModelType.LIST;
else if(Map.class.isAssignableFrom(javaType))
type = ModelType.OBJECT;
else {
throw new RuntimeException("Failed to resolve ModelType for '"+ javaType.getName()+"'");
}
return type;
}
示例4: resolveJavaTypeName
public static Optional<String> resolveJavaTypeName(ModelType modelType, ModelNode value) {
Optional<String> result = Optional.empty();
if(ModelType.STRING == modelType)
{
result = Optional.of("java.lang.String");
}
else if(ModelType.INT == modelType)
{
result = Optional.of("java.lang.Integer");
}
else if(ModelType.LONG == modelType)
{
result = Optional.of("java.lang.Long");
}
else if(ModelType.BOOLEAN == modelType)
{
result = Optional.of("java.lang.Boolean");
}
else if(ModelType.DOUBLE == modelType)
{
result = Optional.of("java.lang.Double");
}
else if(ModelType.BIG_DECIMAL == modelType )
{
result = Optional.of("java.math.BigDecimal");
}
else if (ModelType.OBJECT == modelType) {
result = Optional.of("java.util.Map");
}
else if (ModelType.LIST == modelType) {
result = Optional.of("java.util.List<" + resolveValueType(value) +">");
}
else
{
logger.warning("Unsupported type "+modelType);
}
return result;
}
示例5: fromDMR
/**
* Converts a DMR {@link ModelNode} to a java entity of type T.
*
* @param modelNode a ModelNode
* @return an entity representation of type T
*/
@SuppressWarnings("unchecked")
public T fromDMR(String keyValue, ModelNode modelNode) throws Exception {
if (isBaseTypeAdapter()) return convertToBaseType(modelNode);
ModelNode actualPayload = null;
if (ModelType.OBJECT.equals(modelNode.getType())) {
actualPayload = modelNode;
}
/* else if(ModelType.PROPERTY.equals(modelNode.getType()))
{
final Property property = modelNode.asProperty();
actualPayload = property.getValue();
}*/
else {
throw new IllegalArgumentException("Unsupported ModelType " + modelNode.getType() + ": " + modelNode);
}
ClassInfo clazz = index.getClassByName(DotName.createSimple(getType().getCanonicalName()));
T entity = null;
boolean implicitKey = clazz.annotations().containsKey(IndexFactory.IMPLICIT_META);
if (implicitKey) {
// implicit (aka singleton) resource
Constructor<?> ctor = getType().getConstructor();
entity = (T) ctor.newInstance();
} else {
// explicit (regular) resource
entity = (T) getType().getConstructor(String.class)
.newInstance(keyValue);
}
for (MethodInfo method : clazz.methods()) {
if (method.hasAnnotation(IndexFactory.BINDING_META)) {
Method getter = entity.getClass().getMethod(method.name());
Class<?> propertyType = getter.getReturnType();
ModelNodeBinding binding = getter.getDeclaredAnnotation(ModelNodeBinding.class);
String detypedName = binding.detypedName();
ModelNode dmrPayload = actualPayload.get(detypedName);
// EXPRESSIONS
if(ModelType.EXPRESSION == dmrPayload.getType()) {
ValueExpression expression = dmrPayload.asExpression();
((Map)entity).put(method.name(), expression.getExpressionString());
continue; // expression have precedence over real values
}
// VALUES
ModelType dmrType = Types.resolveModelType(propertyType);
if (dmrType == ModelType.LIST) {
new ListTypeAdapter().fromDmr(entity, method.name(), dmrType, propertyType, dmrPayload);
} else if (dmrType == ModelType.OBJECT) {
new MapTypeAdapter().fromDmr(entity, method.name(), dmrType, propertyType, dmrPayload);
} else {
new SimpleTypeAdapter().fromDmr(entity, method.name(), dmrType, propertyType, dmrPayload);
}
}
}
return entity;
}
示例6: fetchNodes
@SuppressWarnings("unchecked")
@Override
public Map<DMRNodeLocation, ModelNode> fetchNodes(DMRNodeLocation query) throws ProtocolException {
ReadResourceOperationBuilder<?> opBuilder = OperationBuilder
.readResource()//
.address(query.getPathAddress()) //
.includeRuntime();
// time the execute separately - we want to time ONLY the execute call
OperationResult<?> opResult;
try (Context timerContext = diagnostics.getRequestTimer().time()) {
opResult = opBuilder.execute(client);
} catch (Exception e) {
diagnostics.getErrorRate().mark(1);
throw new ProtocolException("Error fetching nodes for query [" + query + "]", e);
}
Optional<ModelNode> resultNode = opResult.getOptionalResultNode();
if (resultNode.isPresent()) {
ModelNode n = resultNode.get();
if (n.getType() == ModelType.OBJECT) {
return Collections.singletonMap(query, n);
} else if (n.getType() == ModelType.LIST) {
Map<DMRNodeLocation, ModelNode> result = new HashMap<>();
List<ModelNode> list = n.asList();
for (ModelNode item : list) {
ModelNode pathAddress = item.get(JBossASClient.ADDRESS);
pathAddress = makePathAddressFullyQualified_WFLY6628(query.getPathAddress(), pathAddress);
result.put(DMRNodeLocation.of(pathAddress, true, true), JBossASClient.getResults(item));
}
return Collections.unmodifiableMap(result);
} else {
throw new IllegalStateException("Invalid type - please report this bug: " + n.getType()
+ " [[" + n.toString() + "]]");
}
} else {
return Collections.emptyMap();
}
}