/** * Returns true if this is a primitive type. */ public boolean isPrimitive() { return !isMessage() && !isEnum(); }
/** * Returns the well-known type kind, or NONE if its not one. */ public WellKnownType getWellKnownType() { if (!isMessage()) { return WellKnownType.NONE; } WellKnownType wkt = WELL_KNOWN_TYPE_MAP.get(messageType.getFullName()); return wkt == null ? WellKnownType.NONE : wkt; }
/** * Returns the well-known type kind, or NONE if its not one. */ public WellKnownType getWellKnownType() { if (!isMessage()) { return WellKnownType.NONE; } WellKnownType wkt = WELL_KNOWN_TYPE_MAP.get(messageType.getFullName()); return wkt == null ? WellKnownType.NONE : wkt; }
/** Returns the Google common type kind, or NONE if its not one. */ public GoogleCommonType getGoogleCommonType() { if (!isMessage()) { return GoogleCommonType.NONE; } GoogleCommonType type = GOOGLE_COMMON_TYPE_MAP.get(messageType.getFullName()); return type == null ? GoogleCommonType.NONE : type; }
@Override public boolean isMessage() { return protoField.getType().isMessage(); }
@Override public boolean isMessage() { return getProtoType().isMessage(); }
/** Returns the Google common type kind, or NONE if its not one. */ public GoogleCommonType getGoogleCommonType() { if (!isMessage()) { return GoogleCommonType.NONE; } GoogleCommonType type = GOOGLE_COMMON_TYPE_MAP.get(messageType.getFullName()); return type == null ? GoogleCommonType.NONE : type; }
/** * Returns true if this is a primitive type. */ public boolean isPrimitive() { return !isMessage() && !isEnum(); }
@Override public boolean apply(TypeRef type) { if (type.getKind() == kind) { if (type.isMessage()) { return type.getMessageType().getFullName().startsWith( typeNamePattern.substring(0, typeNamePattern.length() - 1)); } else if (type.isEnum()) { return type.getEnumType().getFullName().startsWith( typeNamePattern.substring(0, typeNamePattern.length() - 1)); } return false; } return false; } })
@Override public boolean apply(TypeRef type) { if (type.getKind() == kind) { if (type.isMessage()) { return type.getMessageType().getFullName().startsWith( typeNamePattern.substring(0, typeNamePattern.length() - 1)); } else if (type.isEnum()) { return type.getEnumType().getFullName().startsWith( typeNamePattern.substring(0, typeNamePattern.length() - 1)); } return false; } return false; } })
public static boolean s_isEmptyType(TypeRef type) { return type.isMessage() && type.getMessageType().getFullName().equals(Empty.getDescriptor().getFullName()); } }
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; }
private static Set<ProtoFile> getFilesForMessage(MessageType messageType, boolean messageOnly) { Set<ProtoFile> files = newFileSet(); files.add(messageType.getFile()); if (messageOnly) { return files; } for (Field field : messageType.getFields()) { TypeRef type = field.getType(); if (type.isMessage()) { files.addAll(getFilesForMessage(type.getMessageType(), type.isCyclic())); } } return files; }
@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(); }
public List<HeaderRequestParamView> generateHeaderRequestParams(MethodContext context) { if (!context.getProductConfig().getTransportProtocol().equals(TransportProtocol.GRPC)) { return ImmutableList.of(); } GapicMethodConfig methodConfig = (GapicMethodConfig) context.getMethodConfig(); Method method = methodConfig.getMethod(); SurfaceNamer namer = context.getNamer(); if (method.getInputType() == null || !method.getInputType().isMessage()) { return ImmutableList.of(); } ImmutableList.Builder<HeaderRequestParamView> headerRequestParams = ImmutableList.builder(); MessageType inputMessageType = method.getInputType().getMessageType(); for (String headerRequestParam : methodConfig.getHeaderRequestParams()) { headerRequestParams.add( generateHeaderRequestParam(headerRequestParam, inputMessageType, namer)); } return headerRequestParams.build(); }
private void addExtraExtensionTypes() { for (String optionType : foundOptionTypes) { if (isWhitelistedExtensionType(optionType)) { TypeRef typeRef = symbolTable.lookupType(optionType); if (null != typeRef) { ProtoElement element = null; if (typeRef.isMessage()) { element = typeRef.getMessageType(); } else if (typeRef.isEnum()) { element = typeRef.getEnumType(); } if (null != element) { model.addRoot(element); } } } } }
private void addExtraExtensionTypes() { for (String optionType : foundOptionTypes) { if (isWhitelistedExtensionType(optionType)) { TypeRef typeRef = symbolTable.lookupType(optionType); if (null != typeRef) { ProtoElement element = null; if (typeRef.isMessage()) { element = typeRef.getMessageType(); } else if (typeRef.isEnum()) { element = typeRef.getEnumType(); } if (null != element) { model.addRoot(element); } } } } }
@Visits void reach(Field field) { TypeRef type = field.getType(); if (type.isMap()) { visitInScope(type.getMessageType()); if (type.getMapValueField().getType().isMessage()) { // Be sure to generate error message only for the value type, not for the internal // key-value message. However, the later needs to be included, therefore we did // visitInScope above. mustBeInScope(field, type.getMapValueField().getType().getMessageType()); } } else if (type.isMessage()) { mustBeInScope(field, type.getMessageType()); } else if (type.isEnum()) { mustBeInScope(field, type.getEnumType()); } markAsReachable(field); }
@Visits void reach(Field field) { TypeRef type = field.getType(); if (type.isMap()) { visitInScope(type.getMessageType()); if (type.getMapValueField().getType().isMessage()) { // Be sure to generate error message only for the value type, not for the internal // key-value message. However, the later needs to be included, therefore we did // visitInScope above. mustBeInScope(field, type.getMapValueField().getType().getMessageType()); } } else if (type.isMessage()) { mustBeInScope(field, type.getMessageType()); } else if (type.isEnum()) { mustBeInScope(field, type.getEnumType()); } markAsReachable(field); }