aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java
diff options
context:
space:
mode:
authorGravatar corysmith <corysmith@google.com>2018-08-06 12:53:14 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-06 12:54:37 -0700
commit157b917a453ae8ce610accbbad2e292ad649557b (patch)
tree4cf8e8711fe39910aacce7ae8c35ffab35a4c087 /src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java
parent29b57c3afcfeb8e3fedcc2edcb0f28f13c784179 (diff)
Add configuration for android data binding v2.
RELNOTES: None PiperOrigin-RevId: 207592136
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java b/src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java
index 9564643e8e..a5c4c33624 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java
@@ -148,11 +148,11 @@ public final class DataBinding {
}
}
- private static final class EnabledDataBindingContext implements DataBindingContext {
+ private static final class EnabledDataBindingV1Context implements DataBindingContext {
private final ActionConstructionContext actionConstructionContext;
- private EnabledDataBindingContext(ActionConstructionContext actionConstructionContext) {
+ private EnabledDataBindingV1Context(ActionConstructionContext actionConstructionContext) {
this.actionConstructionContext = actionConstructionContext;
}
@@ -269,7 +269,7 @@ public final class DataBinding {
if (o == null || getClass() != o.getClass()) {
return false;
}
- EnabledDataBindingContext that = (EnabledDataBindingContext) o;
+ EnabledDataBindingV1Context that = (EnabledDataBindingV1Context) o;
return Objects.equals(actionConstructionContext, that.actionConstructionContext);
}
@@ -284,28 +284,52 @@ public final class DataBinding {
}
}
+ private static class EnabledDataBindingV2Context implements DataBindingContext {
+
+ private final ActionConstructionContext actionContext;
+
+ private EnabledDataBindingV2Context(ActionConstructionContext actionContext) {
+ this.actionContext = actionContext;
+ throw new UnsupportedOperationException("V2 not implemented yet.");
+ }
+ // TODO(b/112038432): Enable databinding v2.
+ }
+
private static final DataBindingContext DISABLED_CONTEXT = new DataBindingContext() {};
/** Supplies a databinding context from a rulecontext. */
- public static DataBindingContext contextFrom(RuleContext ruleContext) {
+ public static DataBindingContext contextFrom(
+ RuleContext ruleContext, AndroidConfiguration androidConfig) {
if (isEnabled(ruleContext)) {
- return asEnabledDataBindingContextFrom(ruleContext);
+ if (androidConfig.useDataBindingV2()) {
+ return asEnabledDataBindingV2ContextFrom(ruleContext);
+ }
+ return asEnabledDataBindingV1ContextFrom(ruleContext);
}
return asDisabledDataBindingContext();
}
/** Supplies a databinding context from an action context. */
- public static DataBindingContext contextFrom(boolean enabled, ActionConstructionContext context) {
+ public static DataBindingContext contextFrom(
+ boolean enabled, ActionConstructionContext context, AndroidConfiguration androidConfig) {
if (enabled) {
- return asEnabledDataBindingContextFrom(context);
+ if (androidConfig.useDataBindingV2()) {
+ return asEnabledDataBindingV2ContextFrom(context);
+ }
+ return asEnabledDataBindingV1ContextFrom(context);
}
return asDisabledDataBindingContext();
}
/** Supplies an enabled DataBindingContext from the action context. */
- public static DataBindingContext asEnabledDataBindingContextFrom(
+ private static DataBindingContext asEnabledDataBindingV1ContextFrom(
+ ActionConstructionContext actionContext) {
+ return new EnabledDataBindingV1Context(actionContext);
+ }
+
+ private static DataBindingContext asEnabledDataBindingV2ContextFrom(
ActionConstructionContext actionContext) {
- return new EnabledDataBindingContext(actionContext);
+ return new EnabledDataBindingV2Context(actionContext);
}
/** Supplies a disabled (no-op) DataBindingContext. */