String getType(String rtype) { if (rtype.endsWith("[]")) { rtype = rtype.substring(0, rtype.length() - 2); if (rtype.endsWith("[]")) throw new IllegalArgumentException("Can only handle array of depth one"); } if ("boolean".equals(rtype) || Boolean.class.getName().equals(rtype)) return AttributeType.BOOLEAN.toString(); else if ("byte".equals(rtype) || Byte.class.getName().equals(rtype)) return AttributeType.BYTE.toString(); else if ("char".equals(rtype) || Character.class.getName().equals(rtype)) return AttributeType.CHARACTER.toString(); else if ("short".equals(rtype) || Short.class.getName().equals(rtype)) return AttributeType.SHORT.toString(); else if ("int".equals(rtype) || Integer.class.getName().equals(rtype)) return AttributeType.INTEGER.toString(); else if ("long".equals(rtype) || Long.class.getName().equals(rtype)) return AttributeType.LONG.toString(); else if ("float".equals(rtype) || Float.class.getName().equals(rtype)) return AttributeType.FLOAT.toString(); else if ("double".equals(rtype) || Double.class.getName().equals(rtype)) return AttributeType.DOUBLE.toString(); else return AttributeType.STRING.toString(); }
String getType(String rtype) { if (rtype.endsWith("[]")) { rtype = rtype.substring(0, rtype.length() - 2); if (rtype.endsWith("[]")) throw new IllegalArgumentException("Can only handle array of depth one"); } if ("boolean".equals(rtype) || Boolean.class.getName().equals(rtype)) return AttributeType.BOOLEAN.toString(); else if ("byte".equals(rtype) || Byte.class.getName().equals(rtype)) return AttributeType.BYTE.toString(); else if ("char".equals(rtype) || Character.class.getName().equals(rtype)) return AttributeType.CHARACTER.toString(); else if ("short".equals(rtype) || Short.class.getName().equals(rtype)) return AttributeType.SHORT.toString(); else if ("int".equals(rtype) || Integer.class.getName().equals(rtype)) return AttributeType.INTEGER.toString(); else if ("long".equals(rtype) || Long.class.getName().equals(rtype)) return AttributeType.LONG.toString(); else if ("float".equals(rtype) || Float.class.getName().equals(rtype)) return AttributeType.FLOAT.toString(); else if ("double".equals(rtype) || Double.class.getName().equals(rtype)) return AttributeType.DOUBLE.toString(); else return AttributeType.STRING.toString(); }
private void doAD(ADDef ad, Pair pair) throws Exception { AttributeDefinition a = pair.getAd(); Annotation annotation = pair.getA(); if (a.name() != null) { ad.name = a.name(); } ad.description = a.description(); if (a.type() != null) { ad.type = a.type().toString(); } ad.cardinality = a.cardinality(); ad.max = a.max(); ad.min = a.min(); ad.defaults = a.defaultValue(); if (annotation.get("required") != null) { ad.required = a.required(); } if (annotation.get("options") != null) { ad.options.clear(); for (Object o : (Object[])annotation.get("options")) { Option opt = ((Annotation)o).getAnnotation(); ad.options.add(new OptionDef(opt.label(), opt.value())); } } }
private void doAD(ADDef ad, Pair pair) throws Exception { AttributeDefinition a = pair.getAd(); Annotation annotation = pair.getA(); if (a.name() != null) { ad.name = a.name(); } ad.description = a.description(); if (a.type() != null) { ad.type = a.type().toString(); } ad.cardinality = a.cardinality(); ad.max = a.max(); ad.min = a.min(); ad.defaults = a.defaultValue(); if (annotation.get("required") != null) { ad.required = a.required(); } if (annotation.get("options") != null) { ad.options.clear(); for (Object o : (Object[])annotation.get("options")) { Option opt = ((Annotation)o).getAnnotation(); ad.options.add(new OptionDef(opt.label(), opt.value())); } } }