1 20 package net.sf.clirr.core.internal.checks; 21 22 import net.sf.clirr.core.Severity; 23 import net.sf.clirr.core.ScopeSelector; 24 import net.sf.clirr.core.Message; 25 import net.sf.clirr.core.internal.AbstractDiffReporter; 26 import net.sf.clirr.core.internal.ApiDiffDispatcher; 27 import net.sf.clirr.core.internal.ClassChangeCheck; 28 import net.sf.clirr.core.spi.JavaType; 29 import net.sf.clirr.core.spi.Scope; 30 31 48 public final class ClassScopeCheck 49 extends AbstractDiffReporter 50 implements ClassChangeCheck 51 { 52 private static final Message MSG_SCOPE_INCREASED = new Message(1000); 53 private static final Message MSG_SCOPE_DECREASED = new Message(1001); 54 private static final Message MSG_ERROR_DETERMINING_SCOPE_OLD = new Message(1002); 55 private static final Message MSG_ERROR_DETERMINING_SCOPE_NEW = new Message(1003); 56 57 private ScopeSelector scopeSelector; 58 59 63 public ClassScopeCheck(ApiDiffDispatcher dispatcher, ScopeSelector scopeSelector) 64 { 65 super(dispatcher); 66 this.scopeSelector = scopeSelector; 67 } 68 69 70 public boolean check(JavaType compatBaseline, JavaType currentVersion) 71 { 72 Scope bScope = compatBaseline.getEffectiveScope(); 73 Scope cScope = currentVersion.getEffectiveScope(); 74 75 if (!scopeSelector.isSelected(bScope) && !scopeSelector.isSelected(cScope)) 76 { 77 return false; 81 } 82 83 if (cScope.isMoreVisibleThan(bScope)) 84 { 85 String [] args = {bScope.getDesc(), cScope.getDesc()}; 86 87 log(MSG_SCOPE_INCREASED, 88 Severity.INFO, compatBaseline.getName(), null, null, args); 89 } 90 else if (cScope.isLessVisibleThan(bScope)) 91 { 92 String [] args = {bScope.getDesc(), cScope.getDesc()}; 93 94 log(MSG_SCOPE_DECREASED, 95 getSeverity(compatBaseline, Severity.ERROR), 96 compatBaseline.getName(), null, null, args); 97 } 98 99 return scopeSelector.isSelected(bScope) && scopeSelector.isSelected(cScope); 109 } 110 111 } 112 | Popular Tags |