Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.support.annotation.Nullable;
Expand Down
16 changes: 1 addition & 15 deletions epoxy-adapter/src/main/java/com/airbnb/epoxy/DiffHelper.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.support.annotation.Nullable;
Expand Down
16 changes: 1 addition & 15 deletions epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyAdapter.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.os.Bundle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.support.annotation.NonNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.support.annotation.LayoutRes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.support.v4.widget.Space;
Expand Down
15 changes: 0 additions & 15 deletions epoxy-adapter/src/main/java/com/airbnb/epoxy/ModelState.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.support.v4.util.Pools;
Expand Down
15 changes: 0 additions & 15 deletions epoxy-adapter/src/main/java/com/airbnb/epoxy/SimpleEpoxyModel.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.support.annotation.LayoutRes;
Expand Down
16 changes: 1 addition & 15 deletions epoxy-adapter/src/main/java/com/airbnb/epoxy/UpdateOp.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.support.annotation.IntDef;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.os.Parcel;
Expand Down
16 changes: 1 addition & 15 deletions epoxy-model/src/main/java/com/airbnb/epoxy/EpoxyAttribute.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import java.lang.annotation.ElementType;
Expand Down
15 changes: 0 additions & 15 deletions epoxy-model/src/main/java/com/airbnb/epoxy/EpoxyModel.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.support.annotation.LayoutRes;
Expand Down
15 changes: 0 additions & 15 deletions epoxy-processor/src/main/java/com/airbnb/epoxy/AttributeInfo.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import com.squareup.javapoet.AnnotationSpec;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import com.squareup.javapoet.ClassName;
Expand Down
25 changes: 9 additions & 16 deletions epoxy-processor/src/main/java/com/airbnb/epoxy/EpoxyProcessor.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

import android.support.annotation.LayoutRes;
Expand Down Expand Up @@ -178,7 +163,15 @@ private void validateAccessibleViaGeneratedCode(Element attribute) throws
enclosingElement.getSimpleName(), attribute.getSimpleName());
}

// enclosingElement.getNestingKind()
// Nested classes must be static
if (enclosingElement.getNestingKind().isNested()) {
if (!enclosingElement.getModifiers().contains(STATIC)) {
throwError(
"Nested classes with %s annotations must be static. (class: %s, field: %s)",
EpoxyAttribute.class.getSimpleName(),
enclosingElement.getSimpleName(), attribute.getSimpleName());
}
}

// Verify containing type.
if (enclosingElement.getKind() != CLASS) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/*
* Copyright (C) 2016 Airbnb, Inc.
*
* 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.airbnb.epoxy;

class EpoxyProcessorException extends RuntimeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,16 @@ public void testModelThatDoesNotExtendEpoxyModelFails() {
.failsToCompile()
.withErrorContaining("must extend");
}

@Test
public void testModelAsInnerClassFails() {
JavaFileObject model = JavaFileObjects
.forResource("ModelAsInnerClass.java");

assert_().about(javaSource())
.that(model)
.processedWith(new EpoxyProcessor())
.failsToCompile()
.withErrorContaining("Nested classes");
}
}
13 changes: 13 additions & 0 deletions epoxy-processor/src/test/resources/ModelAsInnerClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.airbnb.epoxy;

public class ModelAsInnerClass {

class InnerClass extends EpoxyModel<Object> {
@EpoxyAttribute int valueInt;

@Override
protected int getDefaultLayout() {
return 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ protected int getDefaultLayout() {
return 0;
}

private class Test extends EpoxyModel<Object> {
private static class Test extends EpoxyModel<Object> {
@EpoxyAttribute int value;

@Override
Expand Down