类com.google.protobuf.ProtocolMessageEnum源码实例Demo

下面列出了怎么用com.google.protobuf.ProtocolMessageEnum的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hadoop-ozone   文件: BaseInsightPoint.java
/**
 * Default metrics for any message type based RPC ServerSide translators.
 */
public void addProtocolMessageMetrics(List<MetricGroupDisplay> metrics,
    String prefix,
    Component.Type component,
    ProtocolMessageEnum[] types) {

  MetricGroupDisplay messageTypeCounters =
      new MetricGroupDisplay(component, "Message type counters");
  for (ProtocolMessageEnum type : types) {
    String typeName = type.toString();
    MetricDisplay metricDisplay = new MetricDisplay("Number of " + typeName,
        prefix + "_" + PrometheusMetricsSink
            .normalizeName(typeName));
    messageTypeCounters.addMetrics(metricDisplay);
  }
  metrics.add(messageTypeCounters);
}
 
源代码2 项目: fdb-record-layer   文件: TupleTypeUtil.java
/**
 * Convert a value into a type that can be stored within a {@link Tuple}.
 *
 * @param obj the value to convert
 * @return the value converted to some {@link Tuple}-encodable type
 */
@Nullable
static Object toTupleAppropriateValue(@Nullable Object obj) {
    if (obj instanceof Key.Evaluated.NullStandin) {
        return null;
    } else if (obj instanceof ByteString) {
        return ((ByteString) obj).toByteArray();
    } else if (obj instanceof List) {
        return toTupleAppropriateList((List<?>) obj);
    // Following two are both Internal.EnumLite, so could use that, too.
    } else if (obj instanceof ProtocolMessageEnum) {
        return ((ProtocolMessageEnum) obj).getNumber();
    } else if (obj instanceof Descriptors.EnumValueDescriptor) {
        return ((Descriptors.EnumValueDescriptor) obj).getNumber();
    } else if (obj instanceof FDBRecordVersion) {
        return ((FDBRecordVersion) obj).toVersionstamp(false);
    } else {
        return obj;
    }
}
 
源代码3 项目: saluki   文件: Protobuf2PojoHelp.java
public static final void setPojoFieldValue(Object pojo, String setter, Object protobufValue,
    ProtobufAttribute protobufAttribute, Field field)
    throws InstantiationException, IllegalAccessException, JException {
  Class<? extends Object> argClazz = null;
  if (protobufValue instanceof List) {
    final ArrayList<Object> newCollectionValues = new ArrayList<>();
    newCollectionValues.addAll((Collection<?>) protobufValue);
    protobufValue = newCollectionValues;
    argClazz = ArrayList.class;
  } else if (protobufValue instanceof Map) {
    final Map<Object, Object> newMapValues = new HashMap<>();
    newMapValues.putAll((Map<?, ?>) protobufValue);
    protobufValue = newMapValues;
    argClazz = Map.class;
  } else if (protobufValue instanceof ProtocolMessageEnum) {
    Class<?> fieldType = field.getType();
    protobufValue = JReflectionUtils.runStaticMethod(fieldType, "forNumber",
        ((ProtocolMessageEnum) protobufValue).getNumber());
    argClazz = field.getType();
  } else {
    protobufValue.getClass();
  }
  JReflectionUtils.runSetter(pojo, setter, protobufValue, argClazz);
}
 
源代码4 项目: modeldb   文件: RoleServiceUtils.java
@Override
public List<String> getAccessibleResourceIds(
    CollaboratorBase hostUserInfo,
    CollaboratorBase currentLoginUserInfo,
    ProtocolMessageEnum resourceVisibility,
    ModelDBServiceResourceTypes modelDBServiceResourceTypes,
    List<String> requestedResourceIds) {
  List<String> accessibleResourceIds;
  if (hostUserInfo != null) {
    accessibleResourceIds =
        getReadOnlyAccessibleResourceIds(
            true, hostUserInfo, resourceVisibility, modelDBServiceResourceTypes);
  } else {
    accessibleResourceIds =
        getReadOnlyAccessibleResourceIds(
            false, currentLoginUserInfo, resourceVisibility, modelDBServiceResourceTypes);
  }

  if (requestedResourceIds != null && !requestedResourceIds.isEmpty()) {
    accessibleResourceIds.retainAll(requestedResourceIds);
  }
  return accessibleResourceIds;
}
 
public StorageContainerDatanodeProtocolServerSideTranslatorPB(
    StorageContainerDatanodeProtocol impl,
    ProtocolMessageMetrics<ProtocolMessageEnum> protocolMessageMetrics) {
  this.impl = impl;
  dispatcher =
      new OzoneProtocolMessageDispatcher<>("SCMDatanodeProtocol",
          protocolMessageMetrics,
          LOG);
}
 
/**
 * Creates a new StorageContainerLocationProtocolServerSideTranslatorPB.
 *
 * @param impl            {@link StorageContainerLocationProtocol} server
 *                        implementation
 * @param protocolMetrics
 */
public StorageContainerLocationProtocolServerSideTranslatorPB(
    StorageContainerLocationProtocol impl,
    ProtocolMessageMetrics<ProtocolMessageEnum> protocolMetrics)
    throws IOException {
  this.impl = impl;
  this.dispatcher =
      new OzoneProtocolMessageDispatcher<>("ScmContainerLocation",
          protocolMetrics, LOG);
}
 
/**
 * Creates a new ScmBlockLocationProtocolServerSideTranslatorPB.
 *
 * @param impl {@link ScmBlockLocationProtocol} server implementation
 */
public ScmBlockLocationProtocolServerSideTranslatorPB(
    ScmBlockLocationProtocol impl,
    ProtocolMessageMetrics<ProtocolMessageEnum> metrics)
    throws IOException {
  this.impl = impl;
  dispatcher = new OzoneProtocolMessageDispatcher<>(
      "BlockLocationProtocol", metrics, LOG);

}
 
源代码8 项目: hadoop-ozone   文件: SCMDatanodeProtocolServer.java
/**
 * Get the ProtocolMessageMetrics for this server.
 * @return ProtocolMessageMetrics
 */
protected ProtocolMessageMetrics<ProtocolMessageEnum>
      getProtocolMessageMetrics() {
  return ProtocolMessageMetrics
      .create("SCMDatanodeProtocol", "SCM Datanode protocol",
          StorageContainerDatanodeProtocolProtos.Type.values());
}
 
public OzoneProtocolMessageDispatcher(String serviceName,
    ProtocolMessageMetrics<ProtocolMessageEnum> protocolMessageMetrics,
    Logger logger) {
  this.serviceName = serviceName;
  this.protocolMessageMetrics = protocolMessageMetrics;
  this.logger = logger;
}
 
public RESPONSE processRequest(
    REQUEST request,
    FunctionWithServiceException<REQUEST, RESPONSE> methodCall,
    ProtocolMessageEnum type,
    String traceId) throws ServiceException {
  Span span = TracingUtil.importAndCreateSpan(type.toString(), traceId);
  try {
    if (logger.isTraceEnabled()) {
      logger.trace(
          "[service={}] [type={}] request is received: <json>{}</json>",
          serviceName,
          type.toString(),
          request.toString().replaceAll("\n", "\\\\n"));
    } else if (logger.isDebugEnabled()) {
      logger.debug("{} {} request is received",
          serviceName, type.toString());
    }

    long startTime = System.nanoTime();

    RESPONSE response = methodCall.apply(request);

    protocolMessageMetrics.increment(type, System.nanoTime() - startTime);

    if (logger.isTraceEnabled()) {
      logger.trace(
          "[service={}] [type={}] request is processed. Response: "
              + "<json>{}</json>",
          serviceName,
          type.toString(),
          response.toString().replaceAll("\n", "\\\\n"));
    }
    return response;

  } finally {
    span.finish();
  }
}
 
源代码11 项目: hadoop-ozone   文件: ReconDatanodeProtocolServer.java
@Override
public ProtocolMessageMetrics<ProtocolMessageEnum>
    getProtocolMessageMetrics() {
  return ProtocolMessageMetrics
      .create("ReconDatanodeProtocol", "Recon Datanode protocol",
          StorageContainerDatanodeProtocolProtos.Type.values());
}
 
/**
 * Constructs an instance of the server handler.
 *
 * @param impl OzoneManagerProtocolPB
 */
public OzoneManagerProtocolServerSideTranslatorPB(
    OzoneManager impl,
    OzoneManagerRatisServer ratisServer,
    ProtocolMessageMetrics<ProtocolMessageEnum> metrics,
    boolean enableRatis) {
  this.ozoneManager = impl;
  this.isRatisEnabled = enableRatis;

  if (isRatisEnabled) {
    // In case of ratis is enabled, handler in ServerSideTransaltorPB is used
    // only for read requests and read requests does not require
    // double-buffer to be initialized.
    this.ozoneManagerDoubleBuffer = null;
    handler = new OzoneManagerRequestHandler(impl, null);
  } else {
    this.ozoneManagerDoubleBuffer = new OzoneManagerDoubleBuffer.Builder()
        .setOmMetadataManager(ozoneManager.getMetadataManager())
        // Do nothing.
        // For OM NON-HA code, there is no need to save transaction index.
        // As we wait until the double buffer flushes DB to disk.
        .setOzoneManagerRatisSnapShot((i) -> {
        })
        .enableRatis(isRatisEnabled)
        .enableTracing(TracingUtil.isTracingEnabled(
            ozoneManager.getConfiguration()))
        .build();
    handler = new OzoneManagerRequestHandler(impl, ozoneManagerDoubleBuffer);
  }
  this.omRatisServer = ratisServer;
  dispatcher = new OzoneProtocolMessageDispatcher<>("OzoneProtocol",
      metrics, LOG);

}
 
源代码13 项目: fastjgame   文件: HashTypeMappingStrategy.java
private static byte calNamespace(Class<?> messageClass) {
    if (Message.class.isAssignableFrom(messageClass)) {
        return 1;
    }
    if (ProtocolMessageEnum.class.isAssignableFrom(messageClass)) {
        return 2;
    }
    return 3;
}
 
源代码14 项目: fastjgame   文件: ProtoUtils.java
/**
 * 寻找protobuf枚举的映射信息
 *
 * @param clazz protoBuffer enum
 * @return map
 */
public static <T extends ProtocolMessageEnum> Internal.EnumLiteMap<T> findMapper(@Nonnull Class<T> clazz) {
    Objects.requireNonNull(clazz);
    try {
        final Method method = clazz.getDeclaredMethod("internalGetValueMap");
        method.setAccessible(true);
        @SuppressWarnings("unchecked") final Internal.EnumLiteMap<T> mapper = (Internal.EnumLiteMap<T>) method.invoke(null);
        return mapper;
    } catch (Exception e) {
        throw new IllegalArgumentException("bad class " + clazz.getName(), e);
    }
}
 
源代码15 项目: fastjgame   文件: BinarySerializer.java
/**
 * @param typeModelMapper 类型映射信息
 * @param filter          由于{@link BinarySerializer}支持的消息类是确定的,不能加入,但是允许过滤删除
 */
@SuppressWarnings("unchecked")
public static BinarySerializer newInstance(TypeModelMapper typeModelMapper, Predicate<Class<?>> filter) {
    final Set<Class<?>> supportedClassSet = getFilteredSupportedClasses(filter);
    final List<PojoCodecImpl<?>> codecList = new ArrayList<>(supportedClassSet.size());
    try {
        for (Class<?> messageClazz : supportedClassSet) {
            // protoBuf消息
            if (Message.class.isAssignableFrom(messageClazz)) {
                Parser<?> parser = ProtoUtils.findParser((Class<? extends Message>) messageClazz);
                codecList.add(new ProtoMessageCodec(messageClazz, parser));
                continue;
            }

            // protoBufEnum
            if (ProtocolMessageEnum.class.isAssignableFrom(messageClazz)) {
                final Internal.EnumLiteMap<?> mapper = ProtoUtils.findMapper((Class<? extends ProtocolMessageEnum>) messageClazz);
                codecList.add(new ProtoEnumCodec(messageClazz, mapper));
                continue;
            }

            // 带有DBEntity和SerializableClass注解的所有类,和手写Serializer的类
            final Class<? extends PojoCodecImpl<?>> serializerClass = CodecScanner.getCodecClass(messageClazz);
            if (serializerClass != null) {
                final PojoCodecImpl<?> codec = createCodecInstance(serializerClass);
                codecList.add(new CustomPojoCodec(codec));
                continue;
            }

            throw new IllegalArgumentException("Unsupported class " + messageClazz.getName());
        }

        final CodecRegistry codecRegistry = CodecRegistrys.fromAppPojoCodecs(typeModelMapper, codecList);
        return new BinarySerializer(codecRegistry);
    } catch (Exception e) {
        return ExceptionUtils.rethrow(e);
    }
}
 
源代码16 项目: fdb-record-layer   文件: Comparisons.java
private boolean validForComparand(@Nonnull Descriptors.FieldDescriptor fieldDescriptor) {
    switch (fieldDescriptor.getJavaType()) {
        case BOOLEAN:
            return comparand instanceof Boolean;
        case BYTE_STRING:
            return comparand instanceof ByteString || comparand instanceof byte[];
        case DOUBLE:
            return comparand instanceof Double;
        case FLOAT:
            return comparand instanceof Float;
        case INT:
            return comparand instanceof Integer;
        case LONG:
            return comparand instanceof Long;
        case STRING:
            return comparand instanceof String;
        case ENUM:
            return comparand instanceof ProtocolMessageEnum &&
                  fieldDescriptor.getEnumType().equals(((ProtocolMessageEnum) comparand).getDescriptorForType());
        case MESSAGE:
            final Descriptors.Descriptor descriptor = fieldDescriptor.getMessageType();
            if (!TupleFieldsHelper.isTupleField(descriptor)) {
                return false;
            }
            if (descriptor == TupleFieldsProto.UUID.getDescriptor()) {
                return comparand instanceof UUID;
            }
            return validForComparand(descriptor.findFieldByName("value"));
        default:
            return false;
    }
}
 
源代码17 项目: fdb-record-layer   文件: ScanComparisons.java
public static Object toTupleItem(@Nullable Object item) {
    if (item instanceof ByteString) {
        return ((ByteString) item).toByteArray();
    // Following two are both Internal.EnumLite, so could use that, too.
    } else if (item instanceof ProtocolMessageEnum) {
        return ((ProtocolMessageEnum) item).getNumber();
    } else if (item instanceof Descriptors.EnumValueDescriptor) {
        return ((Descriptors.EnumValueDescriptor) item).getNumber();
    } else if (item instanceof FDBRecordVersion) {
        return ((FDBRecordVersion) item).toVersionstamp();
    } else {
        return item;
    }
}
 
源代码18 项目: fdb-record-layer   文件: TupleTypeUtil.java
/**
 * Normalize a value so that it compares equal to anything with the same {@link Tuple} representation.
 * The value that is returned cannot necessarily be packed by a {@code Tuple} (for example,
 * a <code>byte[]</code> is returned as a {@link ByteString}), but it does implement {@link Object#equals(Object)}
 * and {@link Object#hashCode()}, so the value can be used in hash-based data structures like
 * {@link java.util.HashSet HashSet}s and {@link java.util.HashMap HashMap}s. In other words, it should
 * bethe case that:
 *
 * <pre> {@code
 *   Objects.equals(toTupleEquivalentValue(value1), toTupleEquivalentValue(value2))
 *     == Arrays.equals(Tuple.from(value1).pack(), Tuple.from(value2).pack())
 * }</pre>
 *
 * <p>
 * for any two values {@code value1} and {@code value2}.
 * </p>
 *
 * <p>
 * This will only return {@code null} if {@link #toTupleAppropriateValue(Object)} would return {@code null}
 * on the same input. If the object is already in
 * </p>
 *
 * @param obj the value to normalize
 * @return a value that has the same representation when {@link Tuple}-encoded
 */
@Nullable
static Object toTupleEquivalentValue(@Nullable Object obj) {
    if (obj == null || obj instanceof Key.Evaluated.NullStandin) {
        return null;
    } else if (obj instanceof List<?>) {
        List<?> list = (List<?>)obj;
        return toTupleEquivalentList(list);
    } else if (obj instanceof Tuple) {
        return toTupleEquivalentList(((Tuple)obj).getItems());
    } else if (obj instanceof byte[]) {
        return ByteString.copyFrom((byte[]) obj);
    } else if ((obj instanceof Byte) || (obj instanceof Short) || (obj instanceof Integer)) {
        return ((Number)obj).longValue();
    } else if (obj instanceof BigInteger) {
        BigInteger bigInt = (BigInteger)obj;
        if (bigInt.compareTo(BIG_INT_MIN_LONG) > 0 && bigInt.compareTo(BIG_INT_MAX_LONG) < 0) {
            return bigInt.longValue();
        } else {
            return bigInt;
        }
    } else if (obj instanceof ProtocolMessageEnum) {
        return (long)((ProtocolMessageEnum)obj).getNumber();
    } else if (obj instanceof Descriptors.EnumValueDescriptor) {
        return (long)((Descriptors.EnumValueDescriptor)obj).getNumber();
    } else if (obj instanceof FDBRecordVersion) {
        return ((FDBRecordVersion)obj).toVersionstamp(false);
    } else {
        return obj;
    }
}
 
源代码19 项目: saluki   文件: Protobuf2PojoHelp.java
@SuppressWarnings("rawtypes")
public static final Object getProtobufFieldValue(Message protoBuf,
    ProtobufAttribute protobufAttribute, Field field)
    throws JException, InstantiationException, IllegalAccessException {
  final String getter = ProtobufSerializerUtils.getProtobufGetter(protobufAttribute, field);
  // This is used to determine if the Protobuf message has populated this value
  Boolean isCollection = Boolean.FALSE;
  if (Collection.class.isAssignableFrom(field.getType())) {
    isCollection = Boolean.TRUE;
  }
  // Go ahead and fun the getter
  Object protobufValue = JReflectionUtils.runMethod(protoBuf, getter, (Object[]) null);
  if (isCollection && ((Collection) protobufValue).isEmpty()) {
    return null;
  }
  // If the field itself is a ProtbufEntity, serialize that!
  if (protobufValue instanceof Message
      && ProtobufSerializerUtils.isProtbufEntity(field.getType())) {
    protobufValue = serializeFromProtobufEntity((Message) protobufValue, field.getType());
  }
  if (protobufValue instanceof Collection) {
    protobufValue = convertCollectionFromProtobufs(field, (Collection<?>) protobufValue);
    if (((Collection) protobufValue).isEmpty()) {
      return null;
    }
  }
  if (protobufValue instanceof ProtocolMessageEnum) {
    protobufValue = JReflectionUtils.runStaticMethod(field.getType(), "forNumber",
        ((ProtocolMessageEnum) protobufValue).getNumber());
  }
  return protobufValue;
}
 
源代码20 项目: beam   文件: ProtoByteBuddyUtils.java
@Override
public Type convert(TypeDescriptor typeDescriptor) {
  if (typeDescriptor.equals(BYTE_STRING_TYPE_DESCRIPTOR)
      || typeDescriptor.isSubtypeOf(BYTE_STRING_TYPE_DESCRIPTOR)) {
    return byte[].class;
  } else if (typeDescriptor.isSubtypeOf(TypeDescriptor.of(ProtocolMessageEnum.class))) {
    return Integer.class;
  } else if (typeDescriptor.equals(PROTO_TIMESTAMP_TYPE_DESCRIPTOR)
      || typeDescriptor.equals(PROTO_DURATION_TYPE_DESCRIPTOR)) {
    return Row.class;
  } else {
    Type type = TYPE_OVERRIDES.get(typeDescriptor);
    return (type != null) ? type : super.convert(typeDescriptor);
  }
}
 
源代码21 项目: modeldb   文件: PublicRoleServiceUtils.java
@Override
public List<String> getAccessibleResourceIds(
    CollaboratorBase hostUserInfo,
    CollaboratorBase currentLoginUserInfo,
    ProtocolMessageEnum resourceVisibility,
    ModelDBServiceResourceTypes modelDBServiceResourceTypes,
    List<String> requestedResourceIds) {
  return requestedResourceIds;
}
 
源代码22 项目: openrtb   文件: OpenRtbJsonUtils.java
/**
 * Writes a enum array if not empty.
 *
 * @see #writeEnum(ProtocolMessageEnum, JsonGenerator)
 */
public static void writeEnums(
    String fieldName, List<? extends ProtocolMessageEnum> enums, JsonGenerator gen)
    throws IOException {
  if (!enums.isEmpty()) {
    gen.writeArrayFieldStart(fieldName);
    for (ProtocolMessageEnum e : enums) {
      writeEnum(e, gen);
    }
    gen.writeEndArray();
  }
}
 
源代码23 项目: fastjgame   文件: ProtoBufferScanner.java
private static boolean isProtoBufferClass(Class<?> messageClazz) {
    return AbstractMessage.class.isAssignableFrom(messageClazz)
            || ProtocolMessageEnum.class.isAssignableFrom(messageClazz);
}
 
源代码24 项目: beam   文件: ProtoByteBuddyUtils.java
@Override
public StackManipulation convert(TypeDescriptor type) {
  if (type.equals(BYTE_STRING_TYPE_DESCRIPTOR)
      || type.isSubtypeOf(BYTE_STRING_TYPE_DESCRIPTOR)) {
    return new Compound(
        readValue,
        MethodInvocation.invoke(
            BYTE_STRING_TYPE
                .getDeclaredMethods()
                .filter(ElementMatchers.named("toByteArray"))
                .getOnly()));
  } else if (type.isSubtypeOf(TypeDescriptor.of(ProtocolMessageEnum.class))) {
    return new Compound(
        readValue,
        MethodInvocation.invoke(
            PROTO_ENUM_TYPE
                .getDeclaredMethods()
                .filter(
                    ElementMatchers.named("getNumber").and(ElementMatchers.takesArguments(0)))
                .getOnly()),
        Assigner.DEFAULT.assign(
            INTEGER_TYPE.asUnboxed().asGenericType(),
            INTEGER_TYPE.asGenericType(),
            Typing.STATIC));
  } else if (type.equals(PROTO_TIMESTAMP_TYPE_DESCRIPTOR)) {
    return new Compound(
        readValue,
        MethodInvocation.invoke(
            new ForLoadedType(ProtoSchemaLogicalTypes.TimestampConvert.class)
                .getDeclaredMethods()
                .filter(ElementMatchers.named("toRow"))
                .getOnly()));
  } else if (type.equals(PROTO_DURATION_TYPE_DESCRIPTOR)) {
    return new Compound(
        readValue,
        MethodInvocation.invoke(
            new ForLoadedType(ProtoSchemaLogicalTypes.DurationConvert.class)
                .getDeclaredMethods()
                .filter(ElementMatchers.named("toRow"))
                .getOnly()));
  } else {
    ForLoadedType wrapperType = WRAPPER_LOADED_TYPES.get(type);
    if (wrapperType != null) {
      MethodDescription.InDefinedShape getValueMethod =
          wrapperType.getDeclaredMethods().filter(ElementMatchers.named("getValue")).getOnly();
      TypeDescription.Generic returnType = getValueMethod.getReturnType();
      StackManipulation stackManipulation =
          new Compound(
              readValue,
              MethodInvocation.invoke(getValueMethod),
              Assigner.DEFAULT.assign(
                  returnType, returnType.asErasure().asBoxed().asGenericType(), Typing.STATIC));
      if (type.equals(PROTO_BYTES_VALUE_TYPE_DESCRIPTOR)) {
        stackManipulation =
            getFactory()
                .createGetterConversions(stackManipulation)
                .convert(BYTE_STRING_TYPE_DESCRIPTOR);
      }
      return stackManipulation;
    }
    return super.convert(type);
  }
}
 
源代码25 项目: beam   文件: ProtoByteBuddyUtils.java
@Override
public StackManipulation convert(TypeDescriptor type) {
  if (type.isSubtypeOf(TypeDescriptor.of(ByteString.class))) {
    return new Compound(
        readValue,
        TypeCasting.to(BYTE_ARRAY_TYPE),
        MethodInvocation.invoke(
            BYTE_STRING_TYPE
                .getDeclaredMethods()
                .filter(
                    ElementMatchers.named("copyFrom")
                        .and(ElementMatchers.takesArguments(BYTE_ARRAY_TYPE)))
                .getOnly()));
  } else if (type.isSubtypeOf(TypeDescriptor.of(ProtocolMessageEnum.class))) {
    ForLoadedType loadedType = new ForLoadedType(type.getRawType());
    // Convert the stored number back to the enum constant.
    return new Compound(
        readValue,
        Assigner.DEFAULT.assign(
            INTEGER_TYPE.asBoxed().asGenericType(),
            INTEGER_TYPE.asUnboxed().asGenericType(),
            Typing.STATIC),
        MethodInvocation.invoke(
            loadedType
                .getDeclaredMethods()
                .filter(
                    ElementMatchers.named("forNumber")
                        .and(ElementMatchers.isStatic().and(ElementMatchers.takesArguments(1))))
                .getOnly()));
  } else if (type.equals(PROTO_TIMESTAMP_TYPE_DESCRIPTOR)) {
    return new Compound(
        readValue,
        MethodInvocation.invoke(
            new ForLoadedType(ProtoSchemaLogicalTypes.TimestampConvert.class)
                .getDeclaredMethods()
                .filter(ElementMatchers.named("toTimestamp"))
                .getOnly()));
  } else if (type.equals(PROTO_DURATION_TYPE_DESCRIPTOR)) {
    return new Compound(
        readValue,
        MethodInvocation.invoke(
            new ForLoadedType(ProtoSchemaLogicalTypes.DurationConvert.class)
                .getDeclaredMethods()
                .filter(ElementMatchers.named("toDuration"))
                .getOnly()));
  } else {
    ForLoadedType wrapperType = WRAPPER_LOADED_TYPES.get(type);
    if (wrapperType != null) {
      if (type.equals(PROTO_BYTES_VALUE_TYPE_DESCRIPTOR)) {
        readValue =
            getFactory()
                .createSetterConversions(readValue)
                .convert(TypeDescriptor.of(ByteString.class));
      }
      MethodDescription.InDefinedShape ofMethod =
          wrapperType.getDeclaredMethods().filter(ElementMatchers.named("of")).getOnly();
      TypeDescription.Generic argumentType = ofMethod.getParameters().get(0).getType();
      return new Compound(
          readValue,
          Assigner.DEFAULT.assign(
              argumentType.asErasure().asBoxed().asGenericType(), argumentType, Typing.STATIC),
          MethodInvocation.invoke(ofMethod));
    } else {
      return super.convert(type);
    }
  }
}
 
源代码26 项目: modeldb   文件: RoleService.java
List<String> getAccessibleResourceIds(
CollaboratorBase hostUserInfo,
CollaboratorBase currentLoginUserInfo,
ProtocolMessageEnum resourceVisibility,
ModelDBServiceResourceTypes modelDBServiceResourceTypes,
List<String> requestedResourceIds);
 
源代码27 项目: modeldb   文件: RoleServiceUtils.java
private List<String> getReadOnlyAccessibleResourceIds(
    boolean isHostUser,
    CollaboratorBase userInfo,
    ProtocolMessageEnum resourceVisibility,
    ModelDBServiceResourceTypes modelDBServiceResourceTypes) {

  Set<String> resourceIdsSet = new HashSet<>();
  if (userInfo != null && userInfo.getVertaId() != null) {
    List<String> accessibleResourceIds;
    if (isHostUser) {
      accessibleResourceIds =
          getAllowedResources(modelDBServiceResourceTypes, ModelDBServiceActions.READ, userInfo);
    } else {
      accessibleResourceIds =
          getSelfAllowedResources(modelDBServiceResourceTypes, ModelDBServiceActions.READ);
    }
    resourceIdsSet.addAll(accessibleResourceIds);
    LOGGER.debug(
        "Accessible " + modelDBServiceResourceTypes + " Ids size is {}",
        accessibleResourceIds.size());
  }

  if (resourceVisibility != null
      && (resourceVisibility.equals(ProjectVisibility.PUBLIC)
          || resourceVisibility.equals(DatasetVisibility.PUBLIC))) {
    UserInfo unsignedUserInfo = authService.getUnsignedUser();
    List<String> publicResourceIds =
        getAllowedResources(
            modelDBServiceResourceTypes,
            ModelDBServiceActions.PUBLIC_READ,
            new CollaboratorUser(authService, unsignedUserInfo));
    LOGGER.debug(
        "Public " + modelDBServiceResourceTypes + " Id size is {}", publicResourceIds.size());

    if (resourceIdsSet.size() > 0) {
      resourceIdsSet.retainAll(publicResourceIds);
    } else {
      resourceIdsSet.addAll(publicResourceIds);
    }
    return new ArrayList<>(resourceIdsSet);
  } else {
    return new ArrayList<>(resourceIdsSet);
  }
}
 
源代码28 项目: compiler   文件: BoaProtoMap.java
/**
 * Returns the {@link Class} representing the Java enumeration of this type.
 */
protected Class<? extends ProtocolMessageEnum> getEnumClass() {
	return null;
}
 
源代码29 项目: compiler   文件: CommentKindProtoMap.java
/** {@inheritDoc} */
@Override
protected Class<? extends ProtocolMessageEnum> getEnumClass() {
	return boa.types.Ast.Comment.CommentKind.class;
}
 
源代码30 项目: compiler   文件: ExpressionKindProtoMap.java
/** {@inheritDoc} */
@Override
protected Class<? extends ProtocolMessageEnum> getEnumClass() {
	return boa.types.Ast.Expression.ExpressionKind.class;
}
 
 类所在包
 类方法
 同包方法