Support AutoValue
AutoValue[1] is a lightweight annotation-processor-based library for implementing classes with simple, obvious value semantics. Add support for AutoValue to build rules and Eclipse project generation. Buck does not currently have an officially-supported interface for specifying annotation processor dependencies[2], so we have to take the slightly ugly approach of monkey-patching java_library and java_test to add annotation processor arguments to each rule that requires annotation processing; hopefully this ugliness can be reduced in the future. [1] https://github.com/google/auto/tree/master/value [2] https://github.com/facebook/buck/issues/85 Change-Id: I8b49d6f9f25d61688b667d964848c6ce106ae4ec
This commit is contained in:
committed by
Shawn Pearce
parent
f4893d3d42
commit
08180de4de
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// 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.gerrit.common;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class AutoValueTest {
|
||||
@AutoValue
|
||||
abstract static class Auto {
|
||||
static Auto create(String val) {
|
||||
return new AutoValue_AutoValueTest_Auto(val);
|
||||
}
|
||||
|
||||
abstract String val();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autoValue() {
|
||||
Auto a = Auto.create("foo");
|
||||
assertThat(a.val()).isEqualTo("foo");
|
||||
assertThat(a.toString()).isEqualTo("Auto{val=foo}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user