/** * Get the column type unqualified as a String * @return the column type */ public String getTypeClsString() { return TypeUtil.unqualifiedName(type.getName()); }
/** * Return the key fields of a given class. * @param classKeys map of classname to set of keys * @param clsName the class name to look up * @return the fields that are class keys for the class */ public static List<FieldDescriptor> getKeyFields(Map<String, List<FieldDescriptor>> classKeys, String clsName) { String className = TypeUtil.unqualifiedName(clsName); return classKeys.get(className); }
/** * Get the column type unqualified as a String * @return the column type */ public String getTypeClsString() { return TypeUtil.unqualifiedName(type.getName()); }
/** * Return the key fields of a given class. * @param classKeys map of classname to set of keys * @param clsName the class name to look up * @return the fields that are class keys for the class */ public static List<FieldDescriptor> getKeyFields(Map<String, List<FieldDescriptor>> classKeys, String clsName) { String className = TypeUtil.unqualifiedName(clsName); return classKeys.get(className); }
/** * For a given classreturn true if it has any identifying fields. An * identifying field is an attribute (not a reference or collection) of the * class that is part of any key defined for that class. * * @param classKeys * map of classname to set of keys * @param clsName * the class name to look up * @return true if the class has any key fields */ public static boolean hasKeyFields(Map<String, List<FieldDescriptor>> classKeys, String clsName) { String className = TypeUtil.unqualifiedName(clsName); List<FieldDescriptor> keys = classKeys.get(className); if (keys != null && (keys.size() > 0)) { return true; } return false; }
/** * Get the type * @return the type */ public String getType() { if (imObj == null) { return null; } String cls = DynamicUtil.getSimpleClassName(imObj.getClass()); return TypeUtil.unqualifiedName(cls); }
/** * Get the type * @return the type */ public String getType() { if (imObj == null) { return null; } String cls = DynamicUtil.getSimpleClassName(imObj.getClass()); return TypeUtil.unqualifiedName(cls); }
/** * Constructor that takes a String name. * * @param name a column name * @param index the number of the column * @param type the type of the column (ClassDescriptor or Class) */ public Column(String name, int index, Class type) { this.name = name; this.index = index; this.type = type; this.path = null; setColumnId(name + "_" + TypeUtil.unqualifiedName(type.getName())); }
/** * Constructor that takes a String name. * * @param name a column name * @param index the number of the column * @param type the type of the column (ClassDescriptor or Class) */ public Column(String name, int index, Class type) { this.name = name; this.index = index; this.type = type; this.path = null; setColumnId(name + "_" + TypeUtil.unqualifiedName(type.getName())); }
private List<BagQuery> getBagQueriesForType(BagQueryConfig config, String type) { List<BagQuery> queries = new ArrayList<BagQuery>(); // some queries should run before the default queries.addAll(config.getPreDefaultBagQueries(TypeUtil.unqualifiedName(type))); // create the default query and put it first in the list queries.add(new BagQuery(config, model, classKeys, type)); // add any queries that are configured for this type queries.addAll(config.getBagQueries(TypeUtil.unqualifiedName(type))); return queries; }
private List<BagQuery> getBagQueriesForType(BagQueryConfig config, String type) { List<BagQuery> queries = new ArrayList<BagQuery>(); // some queries should run before the default queries.addAll(config.getPreDefaultBagQueries(TypeUtil.unqualifiedName(type))); // create the default query and put it first in the list queries.add(new BagQuery(config, model, classKeys, type)); // add any queries that are configured for this type queries.addAll(config.getBagQueries(TypeUtil.unqualifiedName(type))); return queries; }
/** * Return names of the key fields for a given class. * @param classKeys map of classname to set of keys * @param clsName the class name to look up * @return the names of fields that are class keys for the class */ public static List<String> getKeyFieldNames(Map<String, List<FieldDescriptor>> classKeys, String clsName) { String className = TypeUtil.unqualifiedName(clsName); List<String> fieldNames = new ArrayList<String>(); List<FieldDescriptor> keys = classKeys.get(className); if (keys != null) { for (FieldDescriptor key : keys) { fieldNames.add(key.getName()); } } return fieldNames; }
/** * Return names of the key fields for a given class. * @param classKeys map of classname to set of keys * @param clsName the class name to look up * @return the names of fields that are class keys for the class */ public static List<String> getKeyFieldNames(Map<String, List<FieldDescriptor>> classKeys, String clsName) { String className = TypeUtil.unqualifiedName(clsName); List<String> fieldNames = new ArrayList<String>(); List<FieldDescriptor> keys = classKeys.get(className); if (keys != null) { for (FieldDescriptor key : keys) { fieldNames.add(key.getName()); } } return fieldNames; }
/** * Generate a .equals() method for the given class. * @param cld descriptor for class in question * @return generated java code as string */ protected String generateEquals(ClassDescriptor cld) { if (cld.getFieldDescriptorByName("id") != null) { String unqualifiedName = TypeUtil.unqualifiedName(cld.getName()); StringBuffer sb = new StringBuffer(); sb.append(INDENT) .append("@Override public boolean equals(Object o) { return (o instanceof ") .append(unqualifiedName) .append(" && id != null) ? id.equals(((") .append(unqualifiedName) .append(")o).getId()) : this == o; }" + ENDL); return sb.toString(); } else { return ""; } }
/** * Constructor that takes a Path object. * * @param path a Path object * @param name an optional, more human readable description of the Column that will be * returned by getName() - can be null in which case the column name (given by * path.toStringNoConstraints()) will be used * @param index the number of the column * @param type the type of the column (ClassDescriptor or Class) */ public Column(Path path, String name, int index, Class type) { this.path = path; this.name = name; this.index = index; this.type = type; setColumnId(path.toString().substring(0, path.toString().lastIndexOf(".")) + "_" + TypeUtil.unqualifiedName(type.getName())); }
/** * Constructor that takes a Path object. The human readable name for getName() will be * generated from the path. * * @param path a Path object * @param index the number of the column * @param type the type of the column (ClassDescriptor or Class) */ public Column(Path path, int index, Class type) { this.path = path; this.name = path.toStringNoConstraints().replaceAll("[:.](?!\\s)", " > "); this.index = index; this.type = type; setColumnId(path.toString().substring(0, path.toString().lastIndexOf(".")) + "_" + TypeUtil.unqualifiedName(type.getName())); }
/** * {@inheritDoc} */ public boolean equals(Object obj) { if (obj == null) { return false; } try { ResultElement cell = (ResultElement) obj; return (Util.equals(field, cell.getField()) && Util.equals(imObj, cell.getObject())); } catch (ClassCastException e) { throw new ClassCastException("Comparing a ResultsElement with a " + obj.getClass().getName()); } catch (NullPointerException e) { throw new NullPointerException("field = " + field + ", imObj = " + imObj + ", type = " + TypeUtil.unqualifiedName(imObj.getClass().getName())); } }
/** * Constructor that takes a Path object. * * @param path a Path object * @param name an optional, more human readable description of the Column that will be * returned by getName() - can be null in which case the column name (given by * path.toStringNoConstraints()) will be used * @param index the number of the column * @param type the type of the column (ClassDescriptor or Class) */ public Column(Path path, String name, int index, Class type) { this.path = path; this.name = name; this.index = index; this.type = type; setColumnId(path.toString().substring(0, path.toString().lastIndexOf(".")) + "_" + TypeUtil.unqualifiedName(type.getName())); }
/** * Constructor that takes a Path object. The human readable name for getName() will be * generated from the path. * * @param path a Path object * @param index the number of the column * @param type the type of the column (ClassDescriptor or Class) */ public Column(Path path, int index, Class type) { this.path = path; this.name = path.toStringNoConstraints().replaceAll("[:.](?!\\s)", " > "); this.index = index; this.type = type; setColumnId(path.toString().substring(0, path.toString().lastIndexOf(".")) + "_" + TypeUtil.unqualifiedName(type.getName())); }
public void testUnqualifiedName() throws Exception { assertEquals("test", TypeUtil.unqualifiedName("test")); assertEquals("test", TypeUtil.unqualifiedName("package.test")); }