/** * 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(); }
} else if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; List<String> enums = stringProperty.getEnum(); if (CollectionUtils.isNotEmpty(enums)) { type = new EnumType(stringProperty.getTitle(), enums); } else if (isNotBlank(stringProperty.getFormat())) { type = new BasicType(stringProperty.getType(), stringProperty.getTitle(), stringProperty.getFormat()); } else { } else if (property instanceof IntegerProperty) { IntegerProperty integerProperty = (IntegerProperty) property; List<Integer> enums = integerProperty.getEnum(); if (CollectionUtils.isNotEmpty(enums)) { type = new EnumType(integerProperty.getTitle(), enumValuesAsString); } else if (isNotBlank(integerProperty.getFormat())) { type = new BasicType(integerProperty.getType(), integerProperty.getTitle(), integerProperty.getFormat()); } else { type = new BasicType(property.getType(), property.getTitle());
@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"); }
if (byte.class == objectClass || Byte.class == objectClass) { swaggerProperty = new StringProperty("byte"); } else if (char.class == objectClass || Character.class == objectClass) { IntegerProperty property = new IntegerProperty(); property.setMinimum(BigDecimal.valueOf(Short.MIN_VALUE)); property.setMaximum(BigDecimal.valueOf(Short.MAX_VALUE)); swaggerProperty = property; } else if (int.class == objectClass || Integer.class == objectClass) { swaggerProperty = new IntegerProperty(); } 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 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());
@Override public Model getCREATEModel(Representation rep) { return ((ModelImpl) super.getCREATEModel(rep)) .property("datatypeClassname", new StringProperty()) .property("minOccurs", new IntegerProperty()) .property("maxOccurs", new IntegerProperty()) .property("datatypeConfig", new StringProperty()) .property("preferredHandlerClassname", new StringProperty()) .property("handlerConfig", new StringProperty()) .required("datatypeClassname"); }
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 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; } }
property = new StringProperty(); break; case "boolean": property = new BooleanProperty(); break; case "array": case "number": case "integer": property = new IntegerProperty(); break; default:
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; } }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#getCREATEModel(Representation) */ @Override public Model getCREATEModel(Representation rep) { return new ModelImpl() .property("diagnosis", new StringProperty()) .property("encounter", new StringProperty()) .property("condition", new StringProperty()) .property("certainty", new StringProperty()) .property("patient", new StringProperty().example("uuid")) .property("rank", new IntegerProperty()); }
/** * Manually register the Pippo Error class as Swagger model. * * @param swagger * @return a ref for the Error model */ protected RefProperty registerErrorModel(Swagger swagger) { String ref = Error.class.getSimpleName(); if (swagger.getDefinitions() != null && swagger.getDefinitions().containsKey(ref)) { // model already registered return new RefProperty(ref); } ModelImpl model = new ModelImpl(); swagger.addDefinition(ref, model); model.setDescription("an error message"); model.addProperty("statusCode", new IntegerProperty().readOnly().description("http status code")); model.addProperty("statusMessage", new StringProperty().readOnly().description("description of the http status code")); model.addProperty("requestMethod", new StringProperty().readOnly().description("http request method")); model.addProperty("requestUri", new StringProperty().readOnly().description("http request path")); model.addProperty("message", new StringProperty().readOnly().description("application message")); if (settings.isDev()) { // in DEV mode the stacktrace is returned in the error message model.addProperty("stacktrace", new StringProperty().readOnly().description("application stacktrace")); } return new RefProperty(ref); }
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(); List<Long> enums = ((LongProperty) property).getEnum(); if( enums != null && !enums.isEmpty()) { defaultValue = enums.get(0); Float defaultValue = ((FloatProperty) property).getDefault(); Double defaultValue = ((DoubleProperty) property).getDefault(); Boolean defaultValue = ((BooleanProperty)property).getDefault(); output = new BooleanExample( defaultValue == null ? SAMPLE_BOOLEAN_PROPERTY_VALUE : defaultValue.booleanValue());
private static Response constructResponse(int status, String error) { Property statusProp = new IntegerProperty() .description("The status code of the error (also provided in the HTTP header)"); statusProp.setExample(status); Property errorProp = new StringProperty() .description("The error message describing the error"); errorProp.setExample((Object)error); return new Response() .description(error) .schema(new ObjectProperty() .property("status", statusProp) .property("error", errorProp)); }
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()); } }
return ExamplesUtil.generateIntegerExample(property instanceof IntegerProperty ? ((IntegerProperty) property).getEnum() : null); case "number": return 0.0; return true; case "string": return ExamplesUtil.generateStringExample(property.getFormat(), property instanceof StringProperty ? ((StringProperty) property).getEnum() : null); case "ref": if (property instanceof RefProperty) {
protected Operation generateQueryCountOperation(RestQueriesConfiguration.QueryInfo query, RequestMethod method) { Operation operation = new Operation() .tag(query.getEntityName() + " Queries") .produces(APPLICATION_JSON_VALUE) .summary("Return a number of entities in query result") .description("Returns a number of entities that matches the query. You can use the all keyword for " + "the queryNameParam to get the number of all available entities.") .response(200, new Response() .description("Success. Entities count is returned") .schema(new IntegerProperty().description("Entities count"))) .response(403, getErrorResponse("Forbidden. The user doesn't have permissions to read the entity.")) .response(404, getErrorResponse("MetaClass not found or query with the given name not found")); operation.setParameters(generateQueryOpParams(query, method, false)); return operation; }
public void texting(String inc) { IntegerProperty textLength = new IntegerProperty(); Timeline timeline = new Timeline(new KeyFrame(Duration.millis(300)), e -> { textLength.set(textLength.get()+1); labelHeader.setText(inc.substring(0, textLength.get())); }); timeline.setCycleCount(inc.length()); timeline.play(); }
public void texting(String inc) { IntegerProperty textLength = new IntegerProperty(); Timeline timeline = new Timeline(new KeyFrame(Duration.millis(300 * inc.length())), new KeyValue(textLength, inc.length())); labelHeader.textProperty().bind(Bindings.createStringBinding(() -> inc.substring(0, textLength.get()), textLength)); timeline.play(); }
@Override protected IntegerProperty create() { return new IntegerProperty(); }