@Test void setsReturnTypeToArrayWhenInstanceOfJsArray() throws NoSuchMethodException { FunctionEntry.Builder builder = new FunctionEntry.Builder(); Method functionReturningArray = ApiObject.class.getMethod("stringArray"); builder.setProxiedFunction(functionReturningArray); FunctionEntry entry = builder.build(); StringBuilder descBuilder = new StringBuilder(); entry.createDescription(descBuilder); assertThat(descBuilder.toString()).isEqualTo("{\"type\":\"function\",\"returns\":\"net.davidtanzer.metalshell.jsapi.FunctionEntryTest$StringArray\"}"); }
@Override protected void createDescription(StringBuilder builder) { builder.append("{\"type\":\"function\""); if(proxiedFunction != null) { builder.append(",\"returns\":\"") .append(proxiedFunction.getReturnType().getName()) .append("\""); } builder.append("}"); }
FunctionEntry extends ApiEntry { @Override protected void createDescription(StringBuilder builder) { builder.append("{\"type\":\"function\""); if(proxiedFunction != null) { builder.append(",\"returns\":\"") .append(proxiedFunction.getReturnType().getName()) .append("\""); } builder.append("}"); } }
FunctionEntry extends ApiEntry { @Override protected void createDescription(StringBuilder builder) { builder.append("{\"type\":\"function\""); if(proxiedFunction != null) { builder.append(",\"returns\":\"") .append(proxiedFunction.getReturnType().getName()) .append("\""); } builder.append("}"); } private  FunctionEntry(); }
FunctionEntry extends ApiEntry { @Override protected void createDescription(StringBuilder builder) { builder.append("{\"type\":\"function\""); if(proxiedFunction != null) { builder.append(",\"returns\":\"") .append(proxiedFunction.getReturnType().getName()) .append("\""); } builder.append("}"); } private  FunctionEntry(); Object call(Object self, Object[] args); Method getProxiedFunction(); }
FunctionEntry extends ApiEntry { @Override protected void createDescription(StringBuilder builder) { builder.append("{\"type\":\"function\""); if(proxiedFunction != null) { builder.append(",\"returns\":\"") .append(proxiedFunction.getReturnType().getName()) .append("\""); } builder.append("}"); } private  FunctionEntry(); Object call(Object self, Object[] args); Method getProxiedFunction();  }