I have package ( of java classes ) in my project.Which need to be removed under some requirement. I have to compile my project to target
Highend
and
lowend
Requirement constraints
- Package need to be there in Highend, and should not be there for lowend.
- My code base is same for both the targets
To achive this requiment I want a way to define
class myclass{
static final boolean isEnable = false;
public void API1(){
if(isEnabled){
//function logic
}
}
public boolean API2(){
if(isEnabled){
//function logic
//return value
}
else
return false;
}
}
Although the "static final " private variable provide a solution to reduce my class size as the is the isEnabled code is false. the compiler remove the bytecode from the complied class.But using this I think it won't solve my problem, it reduces the class size for lowend target But the the function persist which return some default value. Is there any better way or design pattern is solve this problem, as with the current solution I have to made changes in all API of the classes present in the package, Although I have to remove all complete package.
This requirement is related to a java package in Android, So I am including it Android in the tags