本文整理汇总了Java中com.google.protobuf.ProtocolStringList类的典型用法代码示例。如果您正苦于以下问题:Java ProtocolStringList类的具体用法?Java ProtocolStringList怎么用?Java ProtocolStringList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProtocolStringList类属于com.google.protobuf包,在下文中一共展示了ProtocolStringList类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateFile
import com.google.protobuf.ProtocolStringList; //导入依赖的package包/类
public void generateFile(String protoPath) {
try {
if (pojoTypes == null) {
pojoTypes = Maps.newHashMap();
}
} finally {
if (!new File(protoPath).exists()) {
logger.warn("protoPath:" + protoPath
+ " not exist, it may be in the third party jars, so it can't be generate");
return;
}
FileDescriptorSet fileDescriptorSet = commondProtoc.invoke(protoPath);
for (FileDescriptorProto fdp : fileDescriptorSet.getFileList()) {
Pair<String, String> packageClassName = this.packageClassName(fdp.getOptions());
if (packageClassName == null) {
continue;
}
ProtocolStringList dependencyList = fdp.getDependencyList();
for (Iterator<String> it = dependencyList.iterator(); it.hasNext();) {
String dependencyPath = discoveryRoot + "/" + it.next();
generateFile(dependencyPath);
}
doPrint(fdp, packageClassName.getLeft(), packageClassName.getRight());
}
}
}
示例2: messageForFilter
import com.google.protobuf.ProtocolStringList; //导入依赖的package包/类
private static <M extends Message, B extends Message.Builder> M messageForFilter(
ProtocolStringList filter,
Constructor<B> builderConstructor, Message wholeMessage)
throws InstantiationException,
IllegalAccessException,
InvocationTargetException {
final B builder = builderConstructor.newInstance();
final List<Descriptors.FieldDescriptor> fields = wholeMessage.getDescriptorForType()
.getFields();
for (Descriptors.FieldDescriptor field : fields) {
if (filter.contains(field.getFullName())) {
builder.setField(field, wholeMessage.getField(field));
}
}
@SuppressWarnings("unchecked")
// It's fine as the constructor is of {@code MessageCls.Builder} type.
final M result = (M) builder.build();
return result;
}
示例3: tryRemoveFromGroup
import com.google.protobuf.ProtocolStringList; //导入依赖的package包/类
public static void tryRemoveFromGroup(UnitConfigType.UnitConfig group, String userId) throws CouldNotPerformException,
InterruptedException {
UnitConfigType.UnitConfig.Builder unitConfig = Registries.getUserRegistry().getAuthorizationGroupConfigById(group.getId()).toBuilder();
AuthorizationGroupConfigType.AuthorizationGroupConfig.Builder authorizationGroupConfig = unitConfig.getAuthorizationGroupConfigBuilder();
ProtocolStringList members = authorizationGroupConfig.getMemberIdList();
authorizationGroupConfig.clearMemberId();
for (String member : members) {
if (!member.equals(userId)) {
authorizationGroupConfig.addMemberId(member);
}
}
Registries.getUserRegistry().updateAuthorizationGroupConfig(unitConfig.build());
}
示例4: batchRegister
import com.google.protobuf.ProtocolStringList; //导入依赖的package包/类
@Override
public void batchRegister(NetworkAddresses request, StreamObserver<NetworkAddressMappings> responseObserver) {
logger.debug("register application");
ProtocolStringList addressesList = request.getAddressesList();
NetworkAddressMappings.Builder builder = NetworkAddressMappings.newBuilder();
for (int i = 0; i < addressesList.size(); i++) {
String networkAddress = addressesList.get(i);
int addressId = networkAddressIDService.getOrCreate(networkAddress);
if (addressId != 0) {
KeyWithIntegerValue value = KeyWithIntegerValue.newBuilder().setKey(networkAddress).setValue(addressId).build();
builder.addAddressIds(value);
}
}
responseObserver.onNext(builder.build());
responseObserver.onCompleted();
}
示例5: removeDuplicates
import com.google.protobuf.ProtocolStringList; //导入依赖的package包/类
/**
* Cleans the currently built commandHandlers from the duplicates.
*
* <p>Calling this method will cause the {@linkplain #commandHandlers current commandHandlers}
* not to contain duplicate entries in any {@code repeated} field.
*/
private void removeDuplicates() {
final ProtocolStringList handlingTypesList = commandHandlers.getCommandHandlingTypesList();
final Set<String> commandHandlingTypes = newTreeSet(handlingTypesList);
commandHandlers.clearCommandHandlingTypes()
.addAllCommandHandlingTypes(commandHandlingTypes);
}
示例6: verifyMultiplePathsInQuery
import com.google.protobuf.ProtocolStringList; //导入依赖的package包/类
private static void verifyMultiplePathsInQuery(String[] paths,
Query readAllWithPathFilteringQuery) {
final FieldMask fieldMask = readAllWithPathFilteringQuery.getFieldMask();
assertEquals(paths.length, fieldMask.getPathsCount());
final ProtocolStringList pathsList = fieldMask.getPathsList();
for (String expectedPath : paths) {
assertTrue(pathsList.contains(expectedPath));
}
}
示例7: applyMask
import com.google.protobuf.ProtocolStringList; //导入依赖的package包/类
/**
* Applies the given {@code FieldMask} to given collection of {@link Message}s.
* Does not change the {@link Collection} itself.
*
* <p>In case the {@code FieldMask} instance contains invalid field declarations, they are
* ignored and do not affect the execution result.
*
* @param mask {@code FieldMask} to apply to each item of the input {@link Collection}.
* @param messages {@link Message}s to filter.
* @param type type of the {@link Message}s.
* @return messages with the {@code FieldMask} applied
*/
@Nonnull
public static <M extends Message, B extends Message.Builder>
Collection<M> applyMask(FieldMask mask,
Collection<M> messages,
TypeUrl type) {
checkNotNull(mask);
checkNotNull(messages);
checkNotNull(type);
final List<M> filtered = new LinkedList<>();
final ProtocolStringList filter = mask.getPathsList();
final Class<B> builderClass = getBuilderForType(type);
if (filter.isEmpty() || builderClass == null) {
return Collections.unmodifiableCollection(messages);
}
try {
final Constructor<B> builderConstructor = builderClass.getDeclaredConstructor();
builderConstructor.setAccessible(true);
for (Message wholeMessage : messages) {
final M message = messageForFilter(filter, builderConstructor, wholeMessage);
filtered.add(message);
}
} catch (NoSuchMethodException |
InvocationTargetException |
IllegalAccessException |
InstantiationException e) {
// If any reflection failure happens, return all the data without any mask applied.
log().warn(format(CONSTRUCTOR_INVOCATION_ERROR_LOGGING_PATTERN,
builderClass.getCanonicalName()),
e);
return Collections.unmodifiableCollection(messages);
}
return Collections.unmodifiableList(filtered);
}
示例8: doApply
import com.google.protobuf.ProtocolStringList; //导入依赖的package包/类
private static <M extends Message, B extends Message.Builder> M doApply(FieldMask mask,
M message,
TypeUrl type) {
checkNotNull(mask);
checkNotNull(message);
checkNotNull(type);
final ProtocolStringList filter = mask.getPathsList();
final Class<B> builderClass = getBuilderForType(type);
if (builderClass == null) {
return message;
}
try {
final Constructor<B> builderConstructor = builderClass.getDeclaredConstructor();
builderConstructor.setAccessible(true);
final M result = messageForFilter(filter, builderConstructor, message);
return result;
} catch (NoSuchMethodException |
InvocationTargetException |
IllegalAccessException |
InstantiationException e) {
log().warn(format(CONSTRUCTOR_INVOCATION_ERROR_LOGGING_PATTERN,
builderClass.getCanonicalName()),
e);
return message;
}
}
示例9: processElement
import com.google.protobuf.ProtocolStringList; //导入依赖的package包/类
@Override
public void processElement(DoFn<WorkPacketConfig, Map<Integer, List<WorkPacketKey>>>.ProcessContext c)
throws Exception {
long keyCount = 0;
// Now we build the cartesian join and emit each pair forward, we ignore
// self joins and transitive joins {a,b,c} become {a-b,a-c,b-c}
Set<String> transList = new HashSet<String>();
Map<Integer, List<WorkPacketKey>> keysForPartition = new HashMap<>();
ProtocolStringList keyList = c.element().getKeysList();
for (String outer : keyList) {
for (String inner : keyList) {
String key = WorkPacketUtils.createKey(outer, inner);
if (!outer.equals(inner) && !transList.contains(key)) {
int partition = WorkPacketUtils.getMyPartitions(c.element(), key);
++keyCount;
if (!keysForPartition.containsKey(partition)) {
keysForPartition.put(partition, new ArrayList<WorkPacketKey>());
}
keysForPartition.get(partition)
.add(WorkPacketKey.newBuilder().setKey1(inner).setKey2(outer).build());
transList.add(key);
}
}
}
// TODO: Check for empty list
c.output(keysForPartition);
LOG.info(String.format("Number of Keys was %s Number of partitions are %s", keyCount,
c.element().getPartitionLength()));
}