1 19 package org.netbeans.modules.javacore.parser; 20 21 import org.netbeans.modules.javacore.jmiimpl.javamodel.FieldImpl; 22 23 27 class FieldInfoMeasure implements Measure { 28 public static final FieldInfoMeasure INSTANCE = new FieldInfoMeasure(); 29 30 private static final int NAME_WEIGHT = 60; 31 private static final int TYPE_WEIGHT = 40; 32 33 34 private FieldInfoMeasure() { 35 } 36 37 42 public int getDistance(Object refObject, Object ast) { 43 if (ast instanceof FieldInfo) { 44 FieldInfo astInfo = (FieldInfo) ast; 45 FieldImpl refInfo = (FieldImpl) 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 |