1 19 package org.netbeans.modules.javacore.parser; 20 21 import java.lang.reflect.Modifier ; 22 import org.netbeans.jmi.javamodel.Initializer; 23 24 25 29 class InitializerInfoMeasure implements Measure { 30 public static final InitializerInfoMeasure INSTANCE = new InitializerInfoMeasure(); 31 32 33 private InitializerInfoMeasure() { 34 } 35 36 41 public int getDistance(Object refObject, Object ast) { 42 if (ast instanceof FeatureInfo) { 43 FeatureInfo astInfo = (FeatureInfo) ast; 44 Initializer refInfo = (Initializer) refObject; 45 boolean isStatic=Modifier.isStatic(refInfo.getModifiers()); 46 47 if (isStatic && astInfo.infoType==FeatureInfo.STATIC_INITIALIZER_TYPE) 48 return 0; 49 if (!isStatic && astInfo.infoType==FeatureInfo.INSTANCE_INITIALIZER_TYPE) 50 return 0; 51 } 52 return INFINITE_DISTANCE; 53 } 54 } 55 | Popular Tags |