/** * Helper for getting the methods input message. */ // TODO(user): The majority of calls to getInputType and getOutputType just want the // MessageType; substitute them for clarity. public MessageType getInputMessage() { return inputType.getMessageType(); }
/** * Helper for getting the methods output message. */ public MessageType getOutputMessage() { return outputType.getMessageType(); }
/** * Helper for getting the methods output message. */ public MessageType getOutputMessage() { return outputType.getMessageType(); }
private List<String> responseStreamingReturnDocLines(Method method) { return ImmutableList.<String>builder() .add( "@returns {Stream}", " An object stream which emits " + commentReformatter.getLinkedElementName(method.getOutputType().getMessageType()) + " on 'data' event.") .build(); }
@Override public List<ProtoField> getInputFields() { if (inputFields != null) { return inputFields; } ImmutableList.Builder<ProtoField> fieldsBuilder = ImmutableList.builder(); for (Field field : method.getInputType().getMessageType().getFields()) { fieldsBuilder.add(new ProtoField(field)); } inputFields = fieldsBuilder.build(); return inputFields; }
/** Helper to access the full name of the input (request) message of a method. */ public static String getInputMessageName(Method method) { return method.getInputType().getMessageType().getFullName(); } }
/** * Return true of this is a cyclic message type. */ public boolean isCyclic() { return getKind() == Type.TYPE_MESSAGE && getMessageType().isCyclic(); }
/** Helper to access the full name of the input (request) message of a method. */ public static String getInputMessageName(Method method) { return method.getInputType().getMessageType().getFullName(); } }
/** * Return true of this is a cyclic message type. */ public boolean isCyclic() { return getKind() == Type.TYPE_MESSAGE && getMessageType().isCyclic(); }
@Override @Memoized public List<? extends FieldModel> getFields() { return getProtoType() .getMessageType() .getFields() .stream() .map(ProtoField::new) .collect(ImmutableList.toImmutableList()); }
@Override public String getFullNameForMessageType(TypeModel type) { return typeNameConverter .getTypeName(((ProtoTypeRef) type).getProtoType().getMessageType()) .getFullName(); }
public static boolean s_isEmptyType(TypeRef type) { return type.isMessage() && type.getMessageType().getFullName().equals(Empty.getDescriptor().getFullName()); } }
@Override public ProtoField getInputField(String fieldName) { Field inputField = method.getInputType().getMessageType().lookupField(fieldName); return inputField == null ? null : new ProtoField(inputField); }
@Override public ProtoField getOutputField(String fieldName) { Field outputField = method.getOutputType().getMessageType().lookupField(fieldName); return outputField == null ? null : new ProtoField(outputField); }
@Override public GenericFieldSelector getInputFieldSelector(String fieldName) { return new ProtoFieldSelector( FieldSelector.resolve(method.getInputType().getMessageType(), fieldName)); }
private boolean subCyclic(MessageType message) { if (message.isCyclic()) { return true; } for (Field subMessageField : message.getMessageFields()) { if (subCyclic(subMessageField.getType().getMessageType())) { return true; } } return false; } }
private static java.lang.String generateTypeUrl(TypeRef type) { java.lang.String name; if (type.isMessage()) { name = type.getMessageType().getFullName(); } else { name = type.getEnumType().getFullName(); } return DescriptorNormalization.TYPE_SERVICE_BASE_URL + "/" + name; }
private static java.lang.String generateTypeUrl(TypeRef type) { java.lang.String name; if (type.isMessage()) { name = type.getMessageType().getFullName(); } else { name = type.getEnumType().getFullName(); } return DescriptorNormalization.TYPE_SERVICE_BASE_URL + "/" + name; }
@Override public TypeName getTypeNameForElementType(TypeRef type) { switch (type.getKind()) { case TYPE_MESSAGE: return getTypeName(type.getMessageType()); case TYPE_ENUM: return getTypeName(type.getEnumType()); default: String typeName = PRIMITIVE_TYPE_MAP.get(type.getKind()); return typeNameConverter.getTypeName(typeName); } }
@Override public String getTypeNameDoc(ImportTypeTable typeTable, TypeModel typeModel) { TypeRef typeRef = ((ProtoTypeRef) typeModel).getProtoType(); if (typeRef.isMessage()) { return "an object representing " + commentReformatter.getLinkedElementName(typeRef.getMessageType()); } else if (typeRef.isEnum()) { return "a number of " + commentReformatter.getLinkedElementName(typeRef.getEnumType()); } // Converting to lowercase because "String" is capitalized in NodeJSModelTypeNameConverter. return "a " + getParamTypeNoCardinality(typeTable, typeModel).toLowerCase(); }