EnumConstant retainAll(Schema schema, MarkSet markSet) { return new EnumConstant(location, name, tag, documentation, options.retainAll(schema, markSet)); }
Options retainAll(Schema schema, MarkSet markSet) { if (map.isEmpty()) return this; // Nothing to prune. Options result = new Options(optionType, optionElements); Object mapOrNull = retainAll(schema, markSet, optionType, map); result.map = mapOrNull != null ? (ImmutableMap<ProtoMember, Object>) mapOrNull : ImmutableMap.<ProtoMember, Object>of(); return result; }
/** Returns a new proto file that omits types and services not in {@code identifiers}. */ ProtoFile retainAll(Schema schema, MarkSet markSet) { ImmutableList.Builder<Type> retainedTypes = ImmutableList.builder(); for (Type type : types) { Type retainedType = type.retainAll(schema, markSet); if (retainedType != null) { retainedTypes.add(retainedType); } } ImmutableList.Builder<Service> retainedServices = ImmutableList.builder(); for (Service service : services) { Service retainedService = service.retainAll(schema, markSet); if (retainedService != null) { retainedServices.add(retainedService); } } ProtoFile result = new ProtoFile(location, imports, publicImports, packageName, retainedTypes.build(), retainedServices.build(), extendList, options.retainAll(schema, markSet), syntax); result.javaPackage = javaPackage; return result; }
if (!markSet.contains(protoMember)) continue; // Prune this field. Field field = schema.getField(protoMember); Object retainedValue = retainAll(schema, markSet, field.type(), entry.getValue()); if (retainedValue != null) { ImmutableList.Builder<Object> builder = ImmutableList.builder(); for (Object value : ((List) o)) { Object retainedValue = retainAll(schema, markSet, type, value); if (retainedValue != null) {
Rpc retainAll(Schema schema, MarkSet markSet) { if (!markSet.contains(requestType) || !markSet.contains(responseType)) return null; Rpc result = new Rpc(location, name, documentation, requestTypeElement, responseTypeElement, requestStreaming, responseStreaming, options.retainAll(schema, markSet)); result.requestType = requestType; result.responseType = responseType; return result; }
@Override Type retainAll(Schema schema, MarkSet markSet) { // If this type is not retained, prune it. if (!markSet.contains(protoType)) return null; ImmutableList.Builder<EnumConstant> retainedConstants = ImmutableList.builder(); for (EnumConstant constant : constants) { if (markSet.contains(ProtoMember.get(protoType, constant.name()))) { retainedConstants.add(constant.retainAll(schema, markSet)); } } EnumType result = new EnumType(protoType, location, documentation, name, retainedConstants.build(), options.retainAll(schema, markSet)); result.allowAlias = allowAlias; return result; }
Service retainAll(Schema schema, MarkSet markSet) { // If this service is not retained, prune it. if (!markSet.contains(protoType)) { return null; } ImmutableList.Builder<Rpc> retainedRpcs = ImmutableList.builder(); for (Rpc rpc : rpcs) { Rpc retainedRpc = rpc.retainAll(schema, markSet); if (retainedRpc != null && markSet.contains(ProtoMember.get(protoType, rpc.name()))) { retainedRpcs.add(retainedRpc); } } return new Service(protoType, location, documentation, name, retainedRpcs.build(), options.retainAll(schema, markSet)); }
@Override Type retainAll(Schema schema, MarkSet markSet) { ImmutableList.Builder<Type> retainedNestedTypesBuilder = ImmutableList.builder(); for (Type nestedType : nestedTypes) { Type retainedNestedType = nestedType.retainAll(schema, markSet); if (retainedNestedType != null) { retainedNestedTypesBuilder.add(retainedNestedType); } } ImmutableList<Type> retainedNestedTypes = retainedNestedTypesBuilder.build(); if (!markSet.contains(protoType)) { // If this type is not retained, and none of its nested types are retained, prune it. if (retainedNestedTypes.isEmpty()) { return null; } // If this type is not retained but retained nested types, replace it with an enclosing type. return new EnclosingType(location, protoType, documentation, retainedNestedTypes); } ImmutableList.Builder<OneOf> retainedOneOfsBuilder = ImmutableList.builder(); for (OneOf oneOf : oneOfs) { OneOf retainedOneOf = oneOf.retainAll(schema, markSet, protoType); if (retainedOneOf != null) { retainedOneOfsBuilder.add(retainedOneOf); } } ImmutableList<OneOf> retainedOneOfs = retainedOneOfsBuilder.build(); return new MessageType(protoType, location, documentation, name, Field.retainAll(schema, markSet, protoType, declaredFields), Field.retainAll(schema, markSet, protoType, extensionFields), retainedOneOfs, retainedNestedTypes, extensionsList, reserveds, options.retainAll(schema, markSet)); }
Field retainAll(Schema schema, MarkSet markSet) { // For map types only the value can participate in pruning as the key will always be scalar. if (type.isMap() && !markSet.contains(type.valueType())) return null; if (!markSet.contains(type)) return null; Field result = new Field(packageName, location, label, name, documentation, tag, defaultValue, elementType, options.retainAll(schema, markSet), extension); result.type = type; result.deprecated = deprecated; result.packed = packed; result.redacted = redacted; return result; }
EnumConstant retainAll(Schema schema, MarkSet markSet) { return new EnumConstant(location, name, tag, documentation, options.retainAll(schema, markSet)); }
EnumConstant retainAll(Schema schema, MarkSet markSet) { return new EnumConstant(location, name, tag, documentation, options.retainAll(schema, markSet)); }
Options retainAll(Schema schema, MarkSet markSet) { if (map.isEmpty()) return this; // Nothing to prune. Options result = new Options(optionType, optionElements); Object mapOrNull = retainAll(schema, markSet, optionType, map); result.map = mapOrNull != null ? (ImmutableMap<ProtoMember, Object>) mapOrNull : ImmutableMap.<ProtoMember, Object>of(); return result; }
Options retainAll(Schema schema, MarkSet markSet) { if (map.isEmpty()) return this; // Nothing to prune. Options result = new Options(optionType, optionElements); Object mapOrNull = retainAll(schema, markSet, optionType, map); result.map = mapOrNull != null ? (ImmutableMap<ProtoMember, Object>) mapOrNull : ImmutableMap.<ProtoMember, Object>of(); return result; }
Rpc retainAll(Schema schema, MarkSet markSet) { if (!markSet.contains(requestType) || !markSet.contains(responseType)) return null; Rpc result = new Rpc(location, name, documentation, requestTypeElement, responseTypeElement, requestStreaming, responseStreaming, options.retainAll(schema, markSet)); result.requestType = requestType; result.responseType = responseType; return result; }
Rpc retainAll(Schema schema, MarkSet markSet) { if (!markSet.contains(requestType) || !markSet.contains(responseType)) return null; Rpc result = new Rpc(location, name, documentation, requestTypeElement, responseTypeElement, requestStreaming, responseStreaming, options.retainAll(schema, markSet)); result.requestType = requestType; result.responseType = responseType; return result; }
@Override Type retainAll(Schema schema, MarkSet markSet) { // If this type is not retained, prune it. if (!markSet.contains(protoType)) return null; ImmutableList.Builder<EnumConstant> retainedConstants = ImmutableList.builder(); for (EnumConstant constant : constants) { if (markSet.contains(ProtoMember.get(protoType, constant.name()))) { retainedConstants.add(constant.retainAll(schema, markSet)); } } EnumType result = new EnumType(protoType, location, documentation, name, retainedConstants.build(), options.retainAll(schema, markSet)); result.allowAlias = allowAlias; return result; }
Service retainAll(Schema schema, MarkSet markSet) { // If this service is not retained, prune it. if (!markSet.contains(protoType)) { return null; } ImmutableList.Builder<Rpc> retainedRpcs = ImmutableList.builder(); for (Rpc rpc : rpcs) { Rpc retainedRpc = rpc.retainAll(schema, markSet); if (retainedRpc != null && markSet.contains(ProtoMember.get(protoType, rpc.name()))) { retainedRpcs.add(retainedRpc); } } return new Service(protoType, location, documentation, name, retainedRpcs.build(), options.retainAll(schema, markSet)); }
@Override Type retainAll(Schema schema, MarkSet markSet) { // If this type is not retained, prune it. if (!markSet.contains(protoType)) return null; ImmutableList.Builder<EnumConstant> retainedConstants = ImmutableList.builder(); for (EnumConstant constant : constants) { if (markSet.contains(ProtoMember.get(protoType, constant.name()))) { retainedConstants.add(constant.retainAll(schema, markSet)); } } EnumType result = new EnumType(protoType, location, documentation, name, retainedConstants.build(), options.retainAll(schema, markSet)); result.allowAlias = allowAlias; return result; }
Field retainAll(Schema schema, MarkSet markSet) { // For map types only the value can participate in pruning as the key will always be scalar. if (type.isMap() && !markSet.contains(type.valueType())) return null; if (!markSet.contains(type)) return null; Field result = new Field(packageName, location, label, name, documentation, tag, defaultValue, elementType, options.retainAll(schema, markSet), extension); result.type = type; result.deprecated = deprecated; result.packed = packed; result.redacted = redacted; return result; }
Field retainAll(Schema schema, MarkSet markSet) { // For map types only the value can participate in pruning as the key will always be scalar. if (type.isMap() && !markSet.contains(type.valueType())) return null; if (!markSet.contains(type)) return null; Field result = new Field(packageName, location, label, name, documentation, tag, defaultValue, elementType, options.retainAll(schema, markSet), extension); result.type = type; result.deprecated = deprecated; result.packed = packed; result.redacted = redacted; return result; }