public int compare(Object o1, Object o2) { Comparable field1 = (Comparable) accessor.getChildObject(o1); Comparable field2 = (Comparable) accessor.getChildObject(o2); return field1.compareTo(field2); }
public static boolean match(Object query, Object totest, AccessMethod[] fields) { for (int i = 0; i < fields.length; ++ i) { Object querychild = fields[i].getChildObject(query); if (querychild != null) { Object testchild = fields[i].getChildObject(totest); if (!querychild.equals(testchild)) return false; } } return true; } }
private String computeLocalID(Object bean, Object idstrategy, int index) { String localid = null; if (idstrategy instanceof DirectIndexStrategy) { localid = Integer.toString(index); } else { IDRemapStrategy remapstrategy = (IDRemapStrategy) idstrategy; MethodAnalyser ma = darapplier.getMappingContext().getAnalyser( bean.getClass()); AccessMethod sam = ma.getAccessMethod(remapstrategy.idfield); localid = sam.getChildObject(bean).toString(); } return localid; }
public String resolveBean(Object bean) { // A line of code only Andy could love. return mappingcontext.generalLeafParser.render(mappingcontext.getAnalyser(bean.getClass()).getAccessMethod(path).getChildObject(bean)); } };
public Object getProperty(Object parent, String name) { AccessMethod accessmethod = getAccessMethod(name); if (accessmethod == null) { throw UniversalRuntimeException .accumulate(new PropertyException(), "Property " + name + " of object " + parent.getClass() + " not found"); } return accessmethod.getChildObject(parent); }
public boolean areEqual(Object left, Object right) { if (left == null) return right == null; if (right == null) return false; if (left.getClass() != right.getClass()) return false; Class objclass = left.getClass(); if (mappingcontext.generalLeafParser.isLeafType(objclass) || Collection.class.isAssignableFrom(objclass)) { return left.equals(right); } else { MethodAnalyser ma = mappingcontext.getAnalyser(objclass); for (int i = 0; i < ma.allgetters.length; ++i) { AccessMethod sam = ma.allgetters[i]; if (!sam.canGet() || !sam.canSet()) continue; Object leftchild = sam.getChildObject(left); Object rightchild = sam.getChildObject(right); boolean equals = areEqual(leftchild, rightchild); if (!equals) return false; } } return true; }
public Object cloneWithRespect(Object bean, Class respectful) { Class beanclz = bean.getClass(); MethodAnalyser targetma = mappingcontext.getAnalyser(beanclz); MethodAnalyser respectma = mappingcontext.getAnalyser(respectful); Object togo = reflectivecache.construct(beanclz); for (int i = 0; i < targetma.allgetters.length; ++i) { AccessMethod pot = targetma.allgetters[i]; if (!pot.canGet() || !pot.canSet()) continue; String propname = pot.getPropertyName(); if (respectma.getAccessMethod(propname) != null) { Object getit = pot.getChildObject(bean); pot.setChildObject(togo, getit); } } return togo; } }
String bcn = (String) bcnaccess.getChildObject(abd); if (bcn != null) { rbi.beanclass = ClassGetter.forName(bcn);