aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/KeyValueConsumers.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-04-19 22:07:47 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-04-20 11:17:11 +0000
commit66cf13874a3c8f866aeace2d59231e30ca4a5032 (patch)
treee926e87be0c3f8ff8322cd2be20e5a534085010f /src/tools/android/java/com/google/devtools/build/android/KeyValueConsumers.java
parent9b35d8a81b0d5cb92a22e7d9c7bf30a834711d7f (diff)
4 of 5: Serialization of UnwrittenMergedAndroidData.
Adding AndroidDataSerializer, the serialize_format proto, and KeyValueConsumers (utility class for keeping consumers straight). The serializtion is a bit more manual as previous experience has proven to me that simply writing all the resources into a proto map and pulling them out is not performant in the least. So, the serializer stores each message independent, the keys and then the values allowing for potential lazy loading and other optimizations in the future. Also adds tests for parsing and writing style resources. -- MOS_MIGRATED_REVID=120274904
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/KeyValueConsumers.java')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/KeyValueConsumers.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/KeyValueConsumers.java b/src/tools/android/java/com/google/devtools/build/android/KeyValueConsumers.java
new file mode 100644
index 0000000000..86789b27b4
--- /dev/null
+++ b/src/tools/android/java/com/google/devtools/build/android/KeyValueConsumers.java
@@ -0,0 +1,43 @@
+// Copyright 2016 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.android;
+
+import com.google.devtools.build.android.ParsedAndroidData.KeyValueConsumer;
+
+/**
+ * A group of {@link KeyValueConsumer}s for each DataValue type.
+ *
+ * This class acts as a parameter object for organizing the common grouping of consumer instances.
+ */
+class KeyValueConsumers {
+ static KeyValueConsumers of(
+ KeyValueConsumer<DataKey, DataResource> overwritingConsumer,
+ KeyValueConsumer<DataKey, DataResource> nonOverwritingConsumer,
+ KeyValueConsumer<DataKey, DataAsset> assetConsumer) {
+ return new KeyValueConsumers(overwritingConsumer, nonOverwritingConsumer, assetConsumer);
+ }
+
+ final KeyValueConsumer<DataKey, DataResource> overwritingConsumer;
+ final KeyValueConsumer<DataKey, DataResource> nonOverwritingConsumer;
+ final KeyValueConsumer<DataKey, DataAsset> assetConsumer;
+
+ private KeyValueConsumers(
+ KeyValueConsumer<DataKey, DataResource> overwritingConsumer,
+ KeyValueConsumer<DataKey, DataResource> nonOverwritingConsumer,
+ KeyValueConsumer<DataKey, DataAsset> assetConsumer) {
+ this.overwritingConsumer = overwritingConsumer;
+ this.nonOverwritingConsumer = nonOverwritingConsumer;
+ this.assetConsumer = assetConsumer;
+ }
+}