br.com.objectos.core.testing.InheritedTestable Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2015 Objectos, Fábrica de Software LTDA.
*
* 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 br.com.objectos.core.testing;
import java.util.Arrays;
import java.util.List;
import br.com.objectos.pojo.plugin.Naming;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.TypeName;
/**
* @author [email protected] (Marcio Endo)
*/
class InheritedTestable extends SimpleTestable {
public InheritedTestable(Naming naming, TypeName testableOf) {
super(naming, testableOf);
}
@Override
List header() {
ClassName className = naming.superClass();
CodeBlock block = CodeBlock.builder()
.beginControlFlow("if (!$T.class.isInstance(o))", className)
.addStatement("return false")
.endControlFlow()
.addStatement("$T that = $T.class.cast(o)", naming.superClassTypeNameRaw(), className)
.build();
return Arrays.asList(block);
}
@Override
String parameterName() {
return "o";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy