/** * <p> * Applies this schema rule. * </p> * * @param nodeName * the name of the property. * @param mediaNode * the media node * @param parent * the parent node * @param baseType * the type with the media node. This must be java.lang.String. * @param schema * the schema containing the property. * @return byte[] when a binary encoding is specified, baseType otherwise. * @since 0.4.2 */ @Override public JType apply(String nodeName, JsonNode mediaNode, JsonNode parent, JType baseType, Schema schema) { if (!mediaNode.has(BINARY_ENCODING)) { return baseType; } return baseType.owner().ref(byte[].class); } }
/** * Generate getter method name for property. * * @param propertyName * @param type * @param node * @return */ public String getGetterName(String propertyName, JType type, JsonNode node) { propertyName = getPropertyNameForAccessor(propertyName, node); String prefix = type.equals(type.owner()._ref(boolean.class)) ? "is" : "get"; String getterName; if (propertyName.length() > 1 && Character.isUpperCase(propertyName.charAt(1))) { getterName = prefix + propertyName; } else { getterName = prefix + capitalize(propertyName); } if (getterName.equals("getClass")) { getterName = "getClass_"; } return getterName; }
@Override public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) { field.annotate(JsonProperty.class).param("value", propertyName); if (field.type().erasure().equals(field.type().owner().ref(Set.class))) { field.annotate(JsonDeserialize.class).param("as", LinkedHashSet.class); } if (propertyNode.has("javaJsonView")) { field.annotate(JsonView.class).param( "value", field.type().owner().ref(propertyNode.get("javaJsonView").asText())); } if (propertyNode.has("description")) { field.annotate(JsonPropertyDescription.class).param("value", propertyNode.get("description").asText()); } }
@Override public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) { field.annotate(JsonProperty.class).param("value", propertyName); if (field.type().erasure().equals(field.type().owner().ref(Set.class))) { field.annotate(JsonDeserialize.class).param("as", LinkedHashSet.class); } if (propertyNode.has("javaJsonView")) { field.annotate(JsonView.class).param( "value", field.type().owner().ref(propertyNode.get("javaJsonView").asText())); } }
JInvocation invokeCreate = fieldType.owner().ref(URI.class).staticInvoke("create"); return invokeCreate.arg(JExpr.lit(node.asText()));
JType jtype = baseType.owner().ref(type); if (ruleFactory.getGenerationConfig().isUsePrimitives()) { jtype = jtype.unboxify();
JClass setImplClass = fieldType.owner().ref(LinkedHashSet.class); setImplClass = setImplClass.narrow(setGenericType); JInvocation invokeAsList = fieldType.owner().ref(Arrays.class).staticInvoke("asList"); for (JsonNode defaultValue : node) { invokeAsList.arg(getDefaultValue(setGenericType, defaultValue));
JClass listImplClass = fieldType.owner().ref(ArrayList.class); listImplClass = listImplClass.narrow(listGenericType); JInvocation invokeAsList = fieldType.owner().ref(Arrays.class).staticInvoke("asList"); for (JsonNode defaultValue : node) { invokeAsList.arg(getDefaultValue(listGenericType, defaultValue));
PropertyImpl( Mapping parent, FieldOutline fr, QName elementName ) { this.parent = parent; this.fr = fr; this.elementName = elementName; this.codeModel = fr.getRawType().owner(); }
public static boolean isBasicType(final JType type) { final JType[] basicTypes = JTypeUtils.getBasicTypes(type.owner()); return ArrayUtils.contains(basicTypes, type); }
/** * Adds an annotation to this variable. * * @param clazz * The annotation class to annotate the field with */ public JAnnotationUse annotate(Class <? extends Annotation> clazz){ return annotate(type.owner().ref(clazz)); }
/** * Adds an annotation to this variable. * * @param clazz * The annotation class to annotate the field with */ public JAnnotationUse annotate(Class <? extends Annotation> clazz){ return annotate(type.owner().ref(clazz)); }
/** * Adds an annotation to this variable. * * @param clazz * The annotation class to annotate the field with */ public JAnnotationUse annotate(Class <? extends Annotation> clazz){ return annotate(type.owner().ref(clazz)); }
/** Returns true if the given type is a primitive int; false otherwise. */ private boolean isInt(JType type) { JCodeModel codeModel = type.owner(); return type.isPrimitive() && codeModel.INT.equals( JType.parse(codeModel, type.name())); } }
private String getGetterName(String propertyName, JType type) { String prefix = (type.equals(type.owner()._ref(boolean.class))) ? "is" : "get"; propertyName = ruleFactory.getNameHelper().replaceIllegalCharacters(propertyName); String getterName = prefix + capitalize(ruleFactory.getNameHelper().capitalizeTrailingWords(propertyName)); if (getterName.equals("getClass")) { getterName = "getClass_"; } return getterName; }
@Override public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) { field.annotate(JsonProperty.class).param("value", propertyName); if (field.type().erasure().equals(field.type().owner().ref(Set.class))) { field.annotate(JsonDeserialize.class).param("as", LinkedHashSet.class); } if (propertyNode.has("javaJsonView")) { field.annotate(JsonView.class).param( "value", field.type().owner().ref(propertyNode.get("javaJsonView").asText())); } }
public JavaType getCallBackType(){ if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){ JCodeModel cm = _responseBean.getJavaType().getType().getType().owner(); JClass cb = cm.ref(javax.xml.ws.AsyncHandler.class).narrow(_responseBean.getJavaType().getType().getType().boxify()); return new JavaSimpleType(new JAXBTypeAndAnnotation(cb)); } return null; }
public JavaType getCallBackType(){ if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){ JCodeModel cm = _responseBean.getJavaType().getType().getType().owner(); JClass cb = cm.ref(javax.xml.ws.AsyncHandler.class).narrow(_responseBean.getJavaType().getType().getType().boxify()); return new JavaSimpleType(new JAXBTypeAndAnnotation(cb)); } return null; }
public JavaType getResponseBeanJavaType(){ JCodeModel cm = _responseBean.getJavaType().getType().getType().owner(); if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){ JClass future = cm.ref(java.util.concurrent.Future.class).narrow(cm.ref(Object.class).wildcard()); return new JavaSimpleType(new JAXBTypeAndAnnotation(future)); }else if(_asyncOpType.equals(AsyncOperationType.POLLING)){ JClass polling = cm.ref(javax.xml.ws.Response.class).narrow(_responseBean.getJavaType().getType().getType().boxify()); return new JavaSimpleType(new JAXBTypeAndAnnotation(polling)); } return null; }
public JavaType getResponseBeanJavaType(){ JCodeModel cm = _responseBean.getJavaType().getType().getType().owner(); if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){ JClass future = cm.ref(java.util.concurrent.Future.class).narrow(cm.ref(Object.class).wildcard()); return new JavaSimpleType(new JAXBTypeAndAnnotation(future)); }else if(_asyncOpType.equals(AsyncOperationType.POLLING)){ JClass polling = cm.ref(javax.xml.ws.Response.class).narrow(_responseBean.getJavaType().getType().getType().boxify()); return new JavaSimpleType(new JAXBTypeAndAnnotation(polling)); } return null; }