1 19 package org.netbeans.modules.javacore.parser; 20 21 import org.netbeans.modules.javacore.jmiimpl.javamodel.AttributeImpl; 22 23 27 class AttributeInfoMeasure implements Measure { 28 public static final AttributeInfoMeasure INSTANCE = new AttributeInfoMeasure(); 29 30 private static final int NAME_WEIGHT = 60; 31 private static final int TYPE_WEIGHT = 40; 32 33 34 private AttributeInfoMeasure() { 35 } 36 37 42 public int getDistance(Object refObject, Object ast) { 43 if (ast instanceof AttributeInfo) { 44 AttributeInfo astInfo = (AttributeInfo) ast; 45 AttributeImpl refInfo = (AttributeImpl) refObject; 46 int result = StringMeasure.INSTANCE.getDistance(refInfo.getName(),astInfo.name) * NAME_WEIGHT; 47 if (refInfo.isPersisted()) { 48 result += ClassNameMeasure.INSTANCE.getDistance(refInfo.getTypeRef(),astInfo.type) * TYPE_WEIGHT; 49 } 50 result/=100; 51 return result > INFINITE_DISTANCE ? INFINITE_DISTANCE : result; 52 } 53 return INFINITE_DISTANCE; 54 } 55 } 56 | Popular Tags |