/** * Retrieves the default value of a property * * @return the default value of the property */ public Optional<Object> getDefaultValue() { if (property instanceof BooleanProperty) { BooleanProperty booleanProperty = (BooleanProperty) property; return Optional.ofNullable(booleanProperty.getDefault()); } else if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getDefault()); } else if (property instanceof DoubleProperty) { DoubleProperty doubleProperty = (DoubleProperty) property; return Optional.ofNullable(doubleProperty.getDefault()); } else if (property instanceof FloatProperty) { FloatProperty floatProperty = (FloatProperty) property; return Optional.ofNullable(floatProperty.getDefault()); } else if (property instanceof IntegerProperty) { IntegerProperty integerProperty = (IntegerProperty) property; return Optional.ofNullable(integerProperty.getDefault()); } else if (property instanceof LongProperty) { LongProperty longProperty = (LongProperty) property; return Optional.ofNullable(longProperty.getDefault()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getDefault()); } return Optional.empty(); }
@Override public Model getCREATEModel(Representation rep) { return ((ModelImpl) super.getCREATEModel(rep)) .property("format", new StringProperty().example("java.lang.String")) .property("foreignKey", new IntegerProperty()) .property("sortWeight", new DoubleProperty()) .property("searchable", new BooleanProperty()._default(false)) .property("editPrivilege", new RefProperty("#/definitions/PrivilegeCreate")) .required("description"); }
return new StringProperty() .required(annotation.required()) .example(annotation.example().isEmpty() ? null : annotation.example()) .description(annotation.value().isEmpty() ? null : annotation.value()); DoubleProperty property = new DoubleProperty(); property.setRequired(annotation.required()); return property .example(annotation.example()) .description(annotation.value()); FloatProperty property = new FloatProperty(); property.setRequired(annotation.required()); return property .example(annotation.example()) .description(annotation.value()); IntegerProperty property = new IntegerProperty(); property.setRequired(annotation.required()); property.setExample(annotation.example()); return property .description(annotation.value()); LongProperty property = new LongProperty(); property.setRequired(annotation.required()); property.setExample(annotation.example()); return property .description(annotation.value());
private static Map<String, Property> initProperties() { Map<String, Property> properties = new LinkedHashMap<>(); properties.put(PROPERTY_ONE_NAME, new StringProperty() .example(PROPERTY_ONE_EXAMPLE) .required(true) .description(PROPERTY_ONE_DESCRIPTION)); properties.put(PROPERTY_TWO_NAME, new StringProperty() .example(PROPERTY_TWO_EXAMPLE) .required(true) .description(PROPERTY_TWO_DESCRIPTION)); IntegerProperty integerProp = new IntegerProperty(); LongProperty longProp = new LongProperty(); BooleanProperty booleanProp = new BooleanProperty(); integerProp.setExample(""); longProp.setExample(""); booleanProp.setExample(""); properties.put(ARRAY_PROP_NAME, new ArrayProperty().example("").description("")); properties.put(DOUBLE_PROP_NAME, new DoubleProperty().example("").description("")); properties.put(FLOAT_PROP_NAME, new FloatProperty().example("").description("")); properties.put(INTEGER_PROP_NAME, integerProp.description("")); properties.put(LONG_PROP_NAME, longProp.description("")); properties.put(BOOLEAN_PROP_NAME, booleanProp.description("")); properties.put(OBJECT_PROP_NAME, new ObjectProperty().example("").description("")); return properties; } }
if (byte.class == objectClass || Byte.class == objectClass) { swaggerProperty = new StringProperty("byte"); } else if (char.class == objectClass || Character.class == objectClass) { StringProperty property = new StringProperty(); property.setMaxLength(1); swaggerProperty = property; } else if (short.class == objectClass || Short.class == objectClass) { } else if (long.class == objectClass || Long.class == objectClass) { swaggerProperty = new LongProperty(); } else if (float.class == objectClass || Float.class == objectClass) { swaggerProperty = new FloatProperty(); } else if (double.class == objectClass || Double.class == objectClass) { swaggerProperty = new DoubleProperty(); } else if (BigDecimal.class == objectClass) { } else if (boolean.class == objectClass || Boolean.class == objectClass) { swaggerProperty = new BooleanProperty(); } else if (String.class == objectClass) {
protected Property getPrimitiveProperty(String type) { String primitiveType = type; if (type.contains(".")) { primitiveType = primitiveType.substring(primitiveType.lastIndexOf(".") + 1).toLowerCase(); } switch (primitiveType) { case "boolean": return new BooleanProperty().example(true); case "float": case "double": return new DoubleProperty().example("3.14"); case "byte": case "short": case "int": case "integer": return new IntegerProperty().example(42); case "long": return new LongProperty().example(Long.MAX_VALUE >> 4); case "date": return new DateProperty().example("2005-14-10T13:17:42.16Z"); case "uuid": UUIDProperty uuidProp = new UUIDProperty(); uuidProp.setExample("19474a3b-99b5-482e-9e77-852be9adf817"); return uuidProp; case "string": return new StringProperty().example("String"); default: return null; } }
if (_contains) { _matched=true; _switchResult = new StringProperty(); _switchResult = new BooleanProperty(); if (Objects.equal(typeName, "double")) { _matched=true; _switchResult = new DoubleProperty(); if (Objects.equal(typeName, "float")) { _matched=true; _switchResult = new FloatProperty(); if (Objects.equal(typeName, "integer")) { _matched=true; _switchResult = new IntegerProperty(); if (Objects.equal(typeName, "int")) { _matched=true; _switchResult = new IntegerProperty(); if (Objects.equal(typeName, "long")) { _matched=true; _switchResult = new LongProperty();
private Property makeProperty(PropertyDescription pd) { switch (pd.typeName) { case BOOLEAN: return new BooleanProperty(); case BYTES: return new BinaryProperty(); return new DateTimeProperty(); case DOUBLE: return new DoubleProperty(); case ENUM: StringProperty prop = new StringProperty(); if (pd.enumValues != null) { prop._enum(Arrays.asList(pd.enumValues)); return new StringProperty(); case InternetAddressV6: return new StringProperty(); case LONG: return new LongProperty(); case MAP: return new MapProperty(new StringProperty());
@Override public Model getCREATEModel(Representation rep) { return new ModelImpl() .property("ingredient", new StringProperty().example("uuid")) .property("strength", new DoubleProperty()) .property("units", new StringProperty().example("uuid")) .required("ingredient"); }
output = new StringExample(example.toString()); } else { String defaultValue = ((StringProperty)property).getDefault(); List<String> enums = ((StringProperty) property).getEnum(); if( enums != null && !enums.isEmpty()) { defaultValue = enums.get(0); Integer defaultValue = ((IntegerProperty) property).getDefault(); List<Integer> enums = ((IntegerProperty) property).getEnum(); if( enums != null && !enums.isEmpty()) { defaultValue = enums.get(0); Long defaultValue = ((LongProperty) property).getDefault(); Float defaultValue = ((FloatProperty) property).getDefault(); Double defaultValue = ((DoubleProperty) property).getDefault(); List<Double> enums = ((DoubleProperty) property).getEnum(); if( enums != null && !enums.isEmpty()) { defaultValue = enums.get(0); Boolean defaultValue = ((BooleanProperty)property).getDefault(); output = new BooleanExample( defaultValue == null ? SAMPLE_BOOLEAN_PROPERTY_VALUE : defaultValue.booleanValue());
@Override public Model getGETModel(Representation rep) { ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { modelImpl .property("uuid", new StringProperty()) .property("display", new StringProperty()) .property("strength", new DoubleProperty()); } if (rep instanceof DefaultRepresentation) { modelImpl .property("ingredient", new RefProperty("#/definitions/ConceptGetRef")) .property("units", new RefProperty("#/definitions/ConceptGetRef")); } else if (rep instanceof FullRepresentation) { modelImpl .property("ingredient", new RefProperty("#/definitions/ConceptGet")) .property("units", new RefProperty("#/definitions/ConceptGet")); } return modelImpl; }
public void setProperty(Property property) { setType(property.getType()); this.format = property.getFormat(); if (property instanceof StringProperty) { final StringProperty string = (StringProperty) property; setEnum(string.getEnum()); } else if (property instanceof IntegerProperty) { setEnumValue(((IntegerProperty) property).getEnum()); } else if (property instanceof LongProperty) { setEnumValue(((LongProperty) property).getEnum()); } else if (property instanceof FloatProperty) { setEnumValue(((FloatProperty) property).getEnum()); } else if (property instanceof DoubleProperty) { setEnumValue(((DoubleProperty) property).getEnum()); } else if (property instanceof ArrayProperty) { final ArrayProperty array = (ArrayProperty) property; setItems(array.getItems()); } }
@Override protected DoubleProperty create() { return new DoubleProperty(); }
@Override public Model toModel(Property property) { if (isType(property)) { final DoubleProperty resolved = (DoubleProperty) property; final ModelImpl model = createModel(resolved); final Double defaultValue = resolved.getDefault(); if (defaultValue != null) { model.setDefaultValue(defaultValue.toString()); } return model; } return null; } },
@Override public Model getCREATEModel(Representation rep) { OrderResource1_8 orderResource = (OrderResource1_8) Context.getService(RestService.class) .getResourceBySupportedClass(Order.class); ModelImpl orderModel = (ModelImpl) orderResource.getCREATEModel(rep); orderModel .property("dose", new DoubleProperty()) .property("units", new StringProperty()) .property("frequency", new StringProperty()) .property("prn", new BooleanProperty()) .property("complex", new BooleanProperty()) .property("quantity", new IntegerProperty()) .property("drug", new RefProperty("#/definitions/DrugCreate")); // DrugOrders have a specific hardcoded value for this property orderModel.getProperties().remove("orderType"); return orderModel; }
if (byte.class == objectClass || Byte.class == objectClass) { swaggerProperty = new StringProperty("byte"); } else if (char.class == objectClass || Character.class == objectClass) { StringProperty property = new StringProperty(); property.setMaxLength(1); swaggerProperty = property; } else if (short.class == objectClass || Short.class == objectClass) { } else if (long.class == objectClass || Long.class == objectClass) { swaggerProperty = new LongProperty(); } else if (float.class == objectClass || Float.class == objectClass) { swaggerProperty = new FloatProperty(); } else if (double.class == objectClass || Double.class == objectClass) { swaggerProperty = new DoubleProperty(); } else if (BigDecimal.class == objectClass) { } else if (boolean.class == objectClass || Boolean.class == objectClass) { swaggerProperty = new BooleanProperty(); } else if (String.class == objectClass) {
return fillProperty(new BooleanProperty(), mapping); return fillProperty(new IntegerProperty(), mapping); return fillProperty(new LongProperty(), mapping); return fillProperty(new FloatProperty(), mapping); return fillProperty(new DoubleProperty(), mapping); return fillProperty(new StringProperty(), mapping);
output = new StringExample(example.toString()); } else { String defaultValue = ((StringProperty)property).getDefault(); List<String> enums = ((StringProperty) property).getEnum(); if( enums != null && !enums.isEmpty()) { defaultValue = enums.get(0); Integer defaultValue = ((IntegerProperty) property).getDefault(); List<Integer> enums = ((IntegerProperty) property).getEnum(); if( enums != null && !enums.isEmpty()) { defaultValue = enums.get(0); Long defaultValue = ((LongProperty) property).getDefault(); Float defaultValue = ((FloatProperty) property).getDefault(); Double defaultValue = ((DoubleProperty) property).getDefault(); List<Double> enums = ((DoubleProperty) property).getEnum(); if( enums != null && !enums.isEmpty()) { defaultValue = enums.get(0); Boolean defaultValue = ((BooleanProperty)property).getDefault(); output = new BooleanExample( defaultValue == null ? SAMPLE_BOOLEAN_PROPERTY_VALUE : defaultValue.booleanValue());
@Override public Model getCREATEModel(Representation rep) { return ((ModelImpl) super.getCREATEModel(rep)) .property("problem", new RefProperty("#/definitions/ConceptCreate")) .property("modifier", new EnumProperty(ProblemModifier.class)) .property("sortWeight", new DoubleProperty()) .required("problem"); }
@Override public Model getGETModel(Representation rep) { ModelImpl model = (ModelImpl) super.getGETModel(rep); if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { model .property("format", new StringProperty()) .property("foreignKey", new IntegerProperty()) .property("sortWeight", new DoubleProperty()) .property("searchable", new BooleanProperty()._default(false)); } if (rep instanceof DefaultRepresentation) { model .property("editPrivilege", new RefProperty("#/definitions/PrivilegeGetRef")); } else if (rep instanceof FullRepresentation) { model .property("editPrivilege", new RefProperty("#/definitions/PrivilegeGet")) .property("concept", new StringProperty()); } return model; }