/** * 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(); }
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();
if (String.class.isAssignableFrom(fieldType)) property = new StringProperty(); property = new IntegerProperty(); property = new LongProperty(); property = new BooleanProperty(); property = new ArrayProperty(new StringProperty());
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());
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());
@Override protected LongProperty create() { return new LongProperty(); }
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()); } }
private Object getAttribute(final LongProperty prop, final String attr) { Object _xblockexpression = null; { Object _switchResult = null; if (attr != null) { switch (attr) { case "default": _switchResult = prop.getDefault(); break; case "enum": _switchResult = prop.getEnum(); break; } } final Object value = _switchResult; Object _elvis = null; if (value != null) { _elvis = value; } else { Object _attribute = this.getAttribute(((BaseIntegerProperty) prop), attr); _elvis = _attribute; } _xblockexpression = _elvis; } return _xblockexpression; }
@Override public Model toModel(Property property) { if (isType(property)) { final LongProperty resolved = (LongProperty) property; final ModelImpl model = createModel(resolved); final Long defaultValue = resolved.getDefault(); if (defaultValue != null) { model.setDefaultValue(defaultValue.toString()); } return model; } return null; } },
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(); 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());
Property rawLongProperty = new LongProperty(); rawLongProperty.bindBidirectional(someOtherRawProperty);
/** * 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(); }
p.setProperty(new FileProperty()); } else if ("long".equalsIgnoreCase(param.type())) { p.setProperty(new LongProperty()); } else { p.setType(param.type());
@Override public Property resolveProperty(Type type, ModelConverterContext context, Annotation[] annotations, Iterator<ModelConverter> chain) { final JavaType jType = Json.mapper().constructType(type); if (jType != null) { final Class<?> cls = jType.getRawClass(); if (Date.class.isAssignableFrom(cls)) { //DateTimeProperty property = // (DateTimeProperty) chain.next().resolveProperty(type, context, annotations, chain); return new LongProperty(); } } return chain.hasNext() ? chain.next().resolveProperty(type, context, annotations, chain) : null; }