List of usage examples for java.lang Void TYPE
Class TYPE
To view the source code for java.lang Void TYPE.
Click Source Link
From source file:io.coala.json.DynaBean.java
/** * @param referenceType/*ww w . j a va 2 s . c o m*/ * @param <S> * @param <T> * @return */ static final <S, T> JsonDeserializer<T> createJsonDeserializer(final ObjectMapper om, final Class<T> resultType, final Properties... imports) { return new JsonDeserializer<T>() { @Override public T deserializeWithType(final JsonParser jp, final DeserializationContext ctxt, final TypeDeserializer typeDeserializer) throws IOException, JsonProcessingException { return deserialize(jp, ctxt); } @Override public T deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { if (jp.getCurrentToken() == JsonToken.VALUE_NULL) return null; // if( Wrapper.class.isAssignableFrom( resultType ) ) // { // // FIXME // LOG.trace( "deser wrapper intf of {}", jp.getText() ); // return (T) Wrapper.Util.valueOf( jp.getText(), // resultType.asSubclass( Wrapper.class ) ); // } if (Config.class.isAssignableFrom(resultType)) { final Map<String, Object> entries = jp.readValueAs(new TypeReference<Map<String, Object>>() { }); final Iterator<Entry<String, Object>> it = entries.entrySet().iterator(); for (Entry<String, Object> next = null; it.hasNext(); next = it.next()) if (next != null && next.getValue() == null) { LOG.trace("Ignoring null value: {}", next); it.remove(); } return resultType.cast(ConfigFactory.create(resultType.asSubclass(Config.class), entries)); } // else if (Config.class.isAssignableFrom(resultType)) // throw new JsonGenerationException( // "Config does not extend "+Mutable.class.getName()+" required for deserialization: " // + Arrays.asList(resultType // .getInterfaces())); // can't parse directly to interface type final DynaBean bean = new DynaBean(); final TreeNode tree = jp.readValueAsTree(); // override attributes as defined in interface getters final Set<String> attributes = new HashSet<>(); for (Method method : resultType.getMethods()) { if (method.getReturnType().equals(Void.TYPE) || method.getParameterTypes().length != 0) continue; final String attribute = method.getName(); if (attribute.equals("toString") || attribute.equals("hashCode")) continue; attributes.add(attribute); final TreeNode value = tree.get(attribute);// bean.any().get(attributeName); if (value == null) continue; bean.set(method.getName(), om.treeToValue(value, JsonUtil.checkRegistered(om, method.getReturnType(), imports))); } if (tree.isObject()) { // keep superfluous properties as TreeNodes, just in case final Iterator<String> fieldNames = tree.fieldNames(); while (fieldNames.hasNext()) { final String fieldName = fieldNames.next(); if (!attributes.contains(fieldName)) bean.set(fieldName, tree.get(fieldName)); } } else if (tree.isValueNode()) { for (Class<?> type : resultType.getInterfaces()) for (Method method : type.getDeclaredMethods()) { // LOG.trace( "Scanning {}", method ); if (method.isAnnotationPresent(JsonProperty.class)) { final String property = method.getAnnotation(JsonProperty.class).value(); // LOG.trace( "Setting {}: {}", property, // ((ValueNode) tree).textValue() ); bean.set(property, ((ValueNode) tree).textValue()); } } } else throw ExceptionFactory.createUnchecked("Expected {} but parsed: {}", resultType, tree.getClass()); return DynaBean.proxyOf(om, resultType, bean, imports); } }; }
From source file:ch.rasc.extclassgenerator.ModelGenerator.java
private static void createModelBean(ModelBean model, AccessibleObject accessibleObject, OutputConfig outputConfig) {// w ww . j a v a 2s . co m Class<?> javaType = null; String name = null; Class<?> declaringClass = null; if (accessibleObject instanceof Field) { Field field = (Field) accessibleObject; javaType = field.getType(); name = field.getName(); declaringClass = field.getDeclaringClass(); } else if (accessibleObject instanceof Method) { Method method = (Method) accessibleObject; javaType = method.getReturnType(); if (javaType.equals(Void.TYPE)) { return; } if (method.getName().startsWith("get")) { name = StringUtils.uncapitalize(method.getName().substring(3)); } else if (method.getName().startsWith("is")) { name = StringUtils.uncapitalize(method.getName().substring(2)); } else { name = method.getName(); } declaringClass = method.getDeclaringClass(); } ModelType modelType = null; if (model.isAutodetectTypes()) { for (ModelType mt : ModelType.values()) { if (mt.supports(javaType)) { modelType = mt; break; } } } else { modelType = ModelType.AUTO; } ModelFieldBean modelFieldBean = null; ModelField modelFieldAnnotation = accessibleObject.getAnnotation(ModelField.class); if (modelFieldAnnotation != null) { if (StringUtils.hasText(modelFieldAnnotation.value())) { name = modelFieldAnnotation.value(); } if (StringUtils.hasText(modelFieldAnnotation.customType())) { modelFieldBean = new ModelFieldBean(name, modelFieldAnnotation.customType()); } else { ModelType type = null; if (modelFieldAnnotation.type() != ModelType.NOT_SPECIFIED) { type = modelFieldAnnotation.type(); } else { type = modelType; } modelFieldBean = new ModelFieldBean(name, type); } updateModelFieldBean(modelFieldBean, modelFieldAnnotation); model.addField(modelFieldBean); } else { if (modelType != null) { modelFieldBean = new ModelFieldBean(name, modelType); model.addField(modelFieldBean); } } ModelId modelIdAnnotation = accessibleObject.getAnnotation(ModelId.class); if (modelIdAnnotation != null) { model.setIdProperty(name); } ModelClientId modelClientId = accessibleObject.getAnnotation(ModelClientId.class); if (modelClientId != null) { model.setClientIdProperty(name); model.setClientIdPropertyAddToWriter(modelClientId.configureWriter()); } ModelVersion modelVersion = accessibleObject.getAnnotation(ModelVersion.class); if (modelVersion != null) { model.setVersionProperty(name); } ModelAssociation modelAssociationAnnotation = accessibleObject.getAnnotation(ModelAssociation.class); if (modelAssociationAnnotation != null) { model.addAssociation(AbstractAssociation.createAssociation(modelAssociationAnnotation, model, javaType, declaringClass, name)); } if (modelFieldBean != null && outputConfig.getIncludeValidation() != IncludeValidation.NONE) { Set<ModelValidation> modelValidationAnnotations = AnnotationUtils .getRepeatableAnnotation(accessibleObject, ModelValidations.class, ModelValidation.class); if (!modelValidationAnnotations.isEmpty()) { for (ModelValidation modelValidationAnnotation : modelValidationAnnotations) { AbstractValidation modelValidation = AbstractValidation.createValidation(name, modelValidationAnnotation, outputConfig.getIncludeValidation()); if (modelValidation != null) { model.addValidation(modelValidation); } } } else { Annotation[] fieldAnnotations = accessibleObject.getAnnotations(); for (Annotation fieldAnnotation : fieldAnnotations) { AbstractValidation.addValidationToModel(model, modelFieldBean, fieldAnnotation, outputConfig.getIncludeValidation()); } if (accessibleObject instanceof Field) { PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(declaringClass, name); if (pd != null && pd.getReadMethod() != null) { for (Annotation readMethodAnnotation : pd.getReadMethod().getAnnotations()) { AbstractValidation.addValidationToModel(model, modelFieldBean, readMethodAnnotation, outputConfig.getIncludeValidation()); } } } } } }
From source file:io.swagger.jaxrs.SynapseReader.java
public List<String> extractOperationMethods(ApiOperation apiOperation, Method method, Iterator<SwaggerExtension> chain) { ArrayList<String> a = new ArrayList<>(); if (apiOperation != null && apiOperation.httpMethod() != null && !"".equals(apiOperation.httpMethod())) { a.add(apiOperation.httpMethod().toLowerCase()); return a; } else if (method.getAnnotation(RequestMapping.class) != null) { List<String> l = Arrays.asList(method.getAnnotation(RequestMapping.class).method()).stream() .map((org.thingsplode.synapse.core.RequestMethod rm) -> rm.toString().toLowerCase()) .collect(Collectors.toList()); if (l.isEmpty()) { if (method.getParameterCount() > 0 && (method.getAnnotations().length == 0 || method.getAnnotation(RequestBody.class) != null)) { //if there are parameters but not annotated at all or the RequestBody annotation is used l.add("put"); } else if (method.getParameterCount() == 0 && !method.getReturnType().equals(Void.TYPE)) { //if there are no parameters but there's a return type l.add("get"); } else { //if there are no parameters and no return type (void method) l.add("post"); }// w ww . j a v a 2 s .co m } return l; } else if (SynapseEndpointServiceMarker.class.isAssignableFrom(method.getDeclaringClass()) || method.getDeclaringClass().getAnnotation(Service.class) != null) { if (method.getParameterCount() > 0) { a.add("post"); } else { a.add("get"); } //todo: enable this when the service registry will support this differentiation //if (method.getReturnType().equals(Void.TYPE)) { // a.add("post"); //} else { // a.add("get"); //} return a; } else if ((ReflectionUtils.getOverriddenMethod(method)) != null) { return extractOperationMethods(apiOperation, ReflectionUtils.getOverriddenMethod(method), chain); } else if (chain != null && chain.hasNext()) { a.add(chain.next().extractOperationMethod(apiOperation, method, chain)); return a; } else { return a; } }
From source file:com.fiveamsolutions.nci.commons.search.SearchableUtils.java
/** * Get the methods on a given object that are searchable. * //from w w w . j a va2s.c om * @param o object to get methods from * @return list of searchable methods */ public static List<Method> getSearchableMethods(Object o) { List<Method> methods = new ArrayList<Method>(); for (Method m : o.getClass().getMethods()) { if (m.getAnnotation(Searchable.class) != null) { if (m.getReturnType().equals(Void.TYPE)) { throw new IllegalArgumentException( String.format("The @Searchable annotation cannot be applied to %s.%s() [void return]", o.getClass(), m)); } methods.add(m); } } return methods; }
From source file:com.google.gwtjsonrpc.server.JsonServlet.java
private static Map<String, MethodHandle> methods(final RemoteJsonService impl) { final Class<? extends RemoteJsonService> d = findInterface(impl.getClass()); if (d == null) { return Collections.<String, MethodHandle>emptyMap(); }// ww w .ja va2 s.c om final Map<String, MethodHandle> r = new HashMap<String, MethodHandle>(); for (final Method m : d.getMethods()) { if (!Modifier.isPublic(m.getModifiers())) { continue; } if (m.getReturnType() != Void.TYPE) { continue; } final Class<?>[] params = m.getParameterTypes(); if (params.length < 1) { continue; } if (!params[params.length - 1].isAssignableFrom(AsyncCallback.class)) { continue; } final MethodHandle h = new MethodHandle(impl, m); r.put(h.getName(), h); } return Collections.unmodifiableMap(r); }
From source file:com.ctriposs.rest4j.internal.server.model.ResourceModelEncoder.java
@SuppressWarnings("unchecked") private ActionSchemaArray createActions(final ResourceModel resourceModel, final ResourceLevel resourceLevel) { ActionSchemaArray actionsArray = new ActionSchemaArray(); List<ResourceMethodDescriptor> resourceMethodDescriptors = resourceModel.getResourceMethodDescriptors(); Collections.sort(resourceMethodDescriptors, new Comparator<ResourceMethodDescriptor>() { @Override/*from w w w. j a v a 2s . c om*/ public int compare(final ResourceMethodDescriptor o1, final ResourceMethodDescriptor o2) { if (o1.getType().equals(ResourceMethod.ACTION)) { if (o2.getType().equals(ResourceMethod.ACTION)) { return o1.getActionName().compareTo(o2.getActionName()); } else { return 1; } } else if (o2.getType().equals(ResourceMethod.ACTION)) { return -1; } else { return 0; } } }); for (ResourceMethodDescriptor resourceMethodDescriptor : resourceMethodDescriptors) { if (ResourceMethod.ACTION.equals(resourceMethodDescriptor.getType())) { //do not apply entity-level actions at collection level or vice-versa if (resourceMethodDescriptor.getActionResourceLevel() != resourceLevel) { continue; } ActionSchema action = new ActionSchema(); action.setName(resourceMethodDescriptor.getActionName()); String doc = _docsProvider.getMethodDoc(resourceMethodDescriptor.getMethod()); if (doc != null) { action.setDoc(doc); } ParameterSchemaArray parameters = createParameters(resourceMethodDescriptor); if (parameters.size() > 0) { action.setParameters(parameters); } Class<?> returnType = resourceMethodDescriptor.getActionReturnType(); if (returnType != Void.TYPE) { String returnTypeString = buildDataSchemaType(returnType, resourceMethodDescriptor .getActionReturnRecordDataSchema().getField(ActionResponse.VALUE_NAME).getType()); action.setReturns(returnTypeString); } final DataMap customAnnotation = resourceMethodDescriptor.getCustomAnnotationData(); String deprecatedDoc = _docsProvider.getMethodDeprecatedTag(resourceMethodDescriptor.getMethod()); if (deprecatedDoc != null) { customAnnotation.put(DEPRECATED_ANNOTATION_NAME, deprecateDocToAnnotationMap(deprecatedDoc)); } if (!customAnnotation.isEmpty()) { action.setAnnotations(new CustomAnnotationContentSchemaMap(customAnnotation)); } actionsArray.add(action); } } return actionsArray; }
From source file:org.apache.hadoop.hbase.io.HbaseObjectWritable.java
/** * Read a {@link Writable}, {@link String}, primitive type, or an array of * the preceding.//from w w w . ja v a2 s. co m * @param in * @param objectWritable * @param conf * @return the object * @throws IOException */ @SuppressWarnings("unchecked") public static Object readObject(DataInput in, HbaseObjectWritable objectWritable, Configuration conf) throws IOException { Class<?> declaredClass = CODE_TO_CLASS.get(WritableUtils.readVInt(in)); Object instance; if (declaredClass.isPrimitive()) { // primitive types if (declaredClass == Boolean.TYPE) { // boolean instance = Boolean.valueOf(in.readBoolean()); } else if (declaredClass == Character.TYPE) { // char instance = Character.valueOf(in.readChar()); } else if (declaredClass == Byte.TYPE) { // byte instance = Byte.valueOf(in.readByte()); } else if (declaredClass == Short.TYPE) { // short instance = Short.valueOf(in.readShort()); } else if (declaredClass == Integer.TYPE) { // int instance = Integer.valueOf(in.readInt()); } else if (declaredClass == Long.TYPE) { // long instance = Long.valueOf(in.readLong()); } else if (declaredClass == Float.TYPE) { // float instance = Float.valueOf(in.readFloat()); } else if (declaredClass == Double.TYPE) { // double instance = Double.valueOf(in.readDouble()); } else if (declaredClass == Void.TYPE) { // void instance = null; } else { throw new IllegalArgumentException("Not a primitive: " + declaredClass); } } else if (declaredClass.isArray()) { // array if (declaredClass.equals(byte[].class)) { instance = Bytes.readByteArray(in); } else if (declaredClass.equals(Result[].class)) { instance = Result.readArray(in); } else { int length = in.readInt(); instance = Array.newInstance(declaredClass.getComponentType(), length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); } } } else if (declaredClass.equals(Array.class)) { //an array not declared in CLASS_TO_CODE Class<?> componentType = readClass(conf, in); int length = in.readInt(); instance = Array.newInstance(componentType, length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); } } else if (List.class.isAssignableFrom(declaredClass)) { // List int length = in.readInt(); instance = new ArrayList(length); for (int i = 0; i < length; i++) { ((ArrayList) instance).add(readObject(in, conf)); } } else if (declaredClass == String.class) { // String instance = Text.readString(in); } else if (declaredClass.isEnum()) { // enum instance = Enum.valueOf((Class<? extends Enum>) declaredClass, Text.readString(in)); } else if (declaredClass == Message.class) { String className = Text.readString(in); try { declaredClass = getClassByName(conf, className); instance = tryInstantiateProtobuf(declaredClass, in); } catch (ClassNotFoundException e) { LOG.error("Can't find class " + className, e); throw new IOException("Can't find class " + className, e); } } else { // Writable or Serializable Class instanceClass = null; int b = (byte) WritableUtils.readVInt(in); if (b == NOT_ENCODED) { String className = Text.readString(in); try { instanceClass = getClassByName(conf, className); } catch (ClassNotFoundException e) { LOG.error("Can't find class " + className, e); throw new IOException("Can't find class " + className, e); } } else { instanceClass = CODE_TO_CLASS.get(b); } if (Writable.class.isAssignableFrom(instanceClass)) { Writable writable = WritableFactories.newInstance(instanceClass, conf); try { writable.readFields(in); } catch (Exception e) { LOG.error("Error in readFields", e); throw new IOException("Error in readFields", e); } instance = writable; if (instanceClass == NullInstance.class) { // null declaredClass = ((NullInstance) instance).declaredClass; instance = null; } } else { int length = in.readInt(); byte[] objectBytes = new byte[length]; in.readFully(objectBytes); ByteArrayInputStream bis = null; ObjectInputStream ois = null; try { bis = new ByteArrayInputStream(objectBytes); ois = new ObjectInputStream(bis); instance = ois.readObject(); } catch (ClassNotFoundException e) { LOG.error("Class not found when attempting to deserialize object", e); throw new IOException("Class not found when attempting to " + "deserialize object", e); } finally { if (bis != null) bis.close(); if (ois != null) ois.close(); } } } if (objectWritable != null) { // store values objectWritable.declaredClass = declaredClass; objectWritable.instance = instance; } return instance; }
From source file:org.apache.hadoop.hbase.security.access.HbaseObjectWritableFor96Migration.java
/** * Read a {@link Writable}, {@link String}, primitive type, or an array of * the preceding./*w w w . ja v a2 s. c om*/ * @param in * @param objectWritable * @param conf * @return the object * @throws IOException */ @SuppressWarnings("unchecked") static Object readObject(DataInput in, HbaseObjectWritableFor96Migration objectWritable, Configuration conf) throws IOException { Class<?> declaredClass = CODE_TO_CLASS.get(WritableUtils.readVInt(in)); Object instance; if (declaredClass.isPrimitive()) { // primitive types if (declaredClass == Boolean.TYPE) { // boolean instance = Boolean.valueOf(in.readBoolean()); } else if (declaredClass == Character.TYPE) { // char instance = Character.valueOf(in.readChar()); } else if (declaredClass == Byte.TYPE) { // byte instance = Byte.valueOf(in.readByte()); } else if (declaredClass == Short.TYPE) { // short instance = Short.valueOf(in.readShort()); } else if (declaredClass == Integer.TYPE) { // int instance = Integer.valueOf(in.readInt()); } else if (declaredClass == Long.TYPE) { // long instance = Long.valueOf(in.readLong()); } else if (declaredClass == Float.TYPE) { // float instance = Float.valueOf(in.readFloat()); } else if (declaredClass == Double.TYPE) { // double instance = Double.valueOf(in.readDouble()); } else if (declaredClass == Void.TYPE) { // void instance = null; } else { throw new IllegalArgumentException("Not a primitive: " + declaredClass); } } else if (declaredClass.isArray()) { // array if (declaredClass.equals(byte[].class)) { instance = Bytes.readByteArray(in); } else { int length = in.readInt(); instance = Array.newInstance(declaredClass.getComponentType(), length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); } } } else if (declaredClass.equals(Array.class)) { //an array not declared in CLASS_TO_CODE Class<?> componentType = readClass(conf, in); int length = in.readInt(); instance = Array.newInstance(componentType, length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); } } else if (List.class.isAssignableFrom(declaredClass)) { // List int length = in.readInt(); instance = new ArrayList(length); for (int i = 0; i < length; i++) { ((ArrayList) instance).add(readObject(in, conf)); } } else if (declaredClass == String.class) { // String instance = Text.readString(in); } else if (declaredClass.isEnum()) { // enum instance = Enum.valueOf((Class<? extends Enum>) declaredClass, Text.readString(in)); } else if (declaredClass == Message.class) { String className = Text.readString(in); try { declaredClass = getClassByName(conf, className); instance = tryInstantiateProtobuf(declaredClass, in); } catch (ClassNotFoundException e) { LOG.error("Can't find class " + className, e); throw new IOException("Can't find class " + className, e); } } else if (Scan.class.isAssignableFrom(declaredClass)) { int length = in.readInt(); byte[] scanBytes = new byte[length]; in.readFully(scanBytes); ClientProtos.Scan.Builder scanProto = ClientProtos.Scan.newBuilder(); instance = ProtobufUtil.toScan(scanProto.mergeFrom(scanBytes).build()); } else { // Writable or Serializable Class instanceClass = null; int b = (byte) WritableUtils.readVInt(in); if (b == NOT_ENCODED) { String className = Text.readString(in); try { instanceClass = getClassByName(conf, className); } catch (ClassNotFoundException e) { LOG.error("Can't find class " + className, e); throw new IOException("Can't find class " + className, e); } } else { instanceClass = CODE_TO_CLASS.get(b); } if (Writable.class.isAssignableFrom(instanceClass)) { Writable writable = WritableFactories.newInstance(instanceClass, conf); try { writable.readFields(in); } catch (Exception e) { LOG.error("Error in readFields", e); throw new IOException("Error in readFields", e); } instance = writable; if (instanceClass == NullInstance.class) { // null declaredClass = ((NullInstance) instance).declaredClass; instance = null; } } else { int length = in.readInt(); byte[] objectBytes = new byte[length]; in.readFully(objectBytes); ByteArrayInputStream bis = null; ObjectInputStream ois = null; try { bis = new ByteArrayInputStream(objectBytes); ois = new ObjectInputStream(bis); instance = ois.readObject(); } catch (ClassNotFoundException e) { LOG.error("Class not found when attempting to deserialize object", e); throw new IOException("Class not found when attempting to " + "deserialize object", e); } finally { if (bis != null) bis.close(); if (ois != null) ois.close(); } } } if (objectWritable != null) { // store values objectWritable.declaredClass = declaredClass; objectWritable.instance = instance; } return instance; }
From source file:com.linkedin.restli.internal.server.model.ResourceModelEncoder.java
private ActionSchemaArray createActions(final ResourceModel resourceModel, final ResourceLevel resourceLevel) { ActionSchemaArray actionsArray = new ActionSchemaArray(); List<ResourceMethodDescriptor> resourceMethodDescriptors = resourceModel.getResourceMethodDescriptors(); Collections.sort(resourceMethodDescriptors, new Comparator<ResourceMethodDescriptor>() { @Override//from ww w.java2 s. co m public int compare(final ResourceMethodDescriptor o1, final ResourceMethodDescriptor o2) { if (o1.getType().equals(ResourceMethod.ACTION)) { if (o2.getType().equals(ResourceMethod.ACTION)) { return o1.getActionName().compareTo(o2.getActionName()); } else { return 1; } } else if (o2.getType().equals(ResourceMethod.ACTION)) { return -1; } else { return 0; } } }); for (ResourceMethodDescriptor resourceMethodDescriptor : resourceMethodDescriptors) { if (ResourceMethod.ACTION.equals(resourceMethodDescriptor.getType())) { //do not apply entity-level actions at collection level or vice-versa if (resourceMethodDescriptor.getActionResourceLevel() != resourceLevel) { continue; } ActionSchema action = new ActionSchema(); action.setName(resourceMethodDescriptor.getActionName()); //We have to construct the method doc for the action which includes the action return type final String methodDoc = _docsProvider.getMethodDoc(resourceMethodDescriptor.getMethod()); if (methodDoc != null) { final StringBuilder methodDocBuilder = new StringBuilder(methodDoc.trim()); if (methodDocBuilder.length() > 0) { final String returnDoc = sanitizeDoc( _docsProvider.getReturnDoc(resourceMethodDescriptor.getMethod())); if (returnDoc != null && !returnDoc.isEmpty()) { methodDocBuilder.append("\n"); methodDocBuilder.append("Service Returns: "); //Capitalize the first character methodDocBuilder.append(returnDoc.substring(0, 1).toUpperCase()); methodDocBuilder.append(returnDoc.substring(1)); } } action.setDoc(methodDocBuilder.toString()); } ParameterSchemaArray parameters = createParameters(resourceMethodDescriptor); if (parameters.size() > 0) { action.setParameters(parameters); } Class<?> returnType = resourceMethodDescriptor.getActionReturnType(); if (returnType != Void.TYPE) { String returnTypeString = buildDataSchemaType(returnType, resourceMethodDescriptor .getActionReturnRecordDataSchema().getField(ActionResponse.VALUE_NAME).getType()); action.setReturns(returnTypeString); } final DataMap customAnnotation = resourceMethodDescriptor.getCustomAnnotationData(); String deprecatedDoc = _docsProvider.getMethodDeprecatedTag(resourceMethodDescriptor.getMethod()); if (deprecatedDoc != null) { customAnnotation.put(DEPRECATED_ANNOTATION_NAME, deprecateDocToAnnotationMap(deprecatedDoc)); } if (!customAnnotation.isEmpty()) { action.setAnnotations(new CustomAnnotationContentSchemaMap(customAnnotation)); } actionsArray.add(action); } } return actionsArray; }
From source file:org.eclipse.wb.internal.core.model.property.event.ListenerMethodProperty.java
/** * Sometimes we need to tweak it, for example in GWT for TabPanel and * TabListener.onBeforeTabSelected we should return <code>true</code>, not <code>false</code> as * we do in general case.//from w w w .j a va 2 s .c om * * @param methodInfo * * @return body of listener method */ private static List<String> getListenerMethodBody(ListenerMethodInfo methodInfo) { Class<?> returnType = methodInfo.getMethod().getReturnType(); if (returnType == Void.TYPE) { return ImmutableList.of(); } else { String defaultValue = AstParser.getDefaultValue(returnType.getName()); return ImmutableList.of("return " + defaultValue + ";"); } }