/** * Find ClassDescriptor in set with given name. */ private static ClassDescriptor descriptorByName(Set<ClassDescriptor> clds, String name) { for (ClassDescriptor cld : clds) { if (cld.getName().equals(name)) { return cld; } } return null; } }
private void checkModel() { if (!modelSet) { throw new IllegalArgumentException("ClassDescriptor '" + getName() + "' has not been added to a Model"); } }
@Override public int hashCode() { return cld.getName().hashCode(); }
private void checkModel() { if (!modelSet) { throw new IllegalArgumentException("ClassDescriptor '" + getName() + "' has not been added to a Model"); } }
/** * Find ClassDescriptor in set with given name. */ private static ClassDescriptor descriptorByName(Set<ClassDescriptor> clds, String name) { for (ClassDescriptor cld : clds) { if (cld.getName().equals(name)) { return cld; } } return null; } }
/** * Get all the tags that all users have access to. * @param cld The class descriptor that is tagged. * @return The tag names. */ public Collection<String> getPublicTagNames(ClassDescriptor cld) { return getPublicTagNames(cld.getName(), TagTypes.CLASS); }
/** * {@inheritDoc} */ @Override public int hashCode() { return 2 * (cld == null ? 0 : cld.getName().hashCode()) + 3 * name.hashCode() + 7 * referencedType.hashCode() + 11 * Util.hashCode(reverseRefName); }
/** * {@inheritDoc} */ @Override public int hashCode() { return 2 * (cld == null ? 0 : cld.getName().hashCode()) + 3 * name.hashCode() + 7 * referencedType.hashCode() + 11 * Util.hashCode(reverseRefName); }
/** * Get all the tags that all users have access to. * @param cld The class descriptor that is tagged. * @return The tag names. */ public Collection<String> getPublicTagNames(ClassDescriptor cld) { return getPublicTagNames(cld.getName(), TagTypes.CLASS); }
/** * Get a named attribute. * * @param attributeName the attribute name * @return the Attribute with the given name */ public Attribute getAttribute(String attributeName) { if (!checkAttribute(attributeName)) { throw new RuntimeException("class \"" + classDescriptor.getName() + "\" has no \"" + attributeName + "\" attribute"); } return attributes.get(attributeName); }
/** * Associate a class with a certain tag. * @param tagName The tag we want to give this class. * @param cld The descriptor for this class. * @param profile The profile to associate this tag with. * @return A tag object. * @throws TagNameException If the name is invalid (contains illegal characters) * @throws TagNamePermissionException If this tag name is restricted. */ public synchronized Tag addTag(String tagName, ClassDescriptor cld, Profile profile) throws TagNameException, TagNamePermissionException { return addTag(tagName, cld.getName(), TagTypes.CLASS, profile); }
/** * Get a named attribute. * * @param attributeName the attribute name * @return the Attribute with the given name */ public Attribute getAttribute(String attributeName) { if (!checkAttribute(attributeName)) { throw new RuntimeException("class \"" + classDescriptor.getName() + "\" has no \"" + attributeName + "\" attribute"); } return attributes.get(attributeName); }
private Set<ClassDescriptor> findAllSuperDescriptors() { Set<ClassDescriptor> supers = new LinkedHashSet<ClassDescriptor>(); for (ClassDescriptor superCld : this.getSuperDescriptors()) { if (!superCld.getName().equals(INTERMINEOBJECT_NAME)) { supers.add(superCld); supers.addAll(superCld.getAllSuperDescriptors()); } } return supers; } }
private Set<ClassDescriptor> findAllSuperDescriptors() { Set<ClassDescriptor> supers = new LinkedHashSet<ClassDescriptor>(); for (ClassDescriptor superCld : this.getSuperDescriptors()) { if (!superCld.getName().equals(INTERMINEOBJECT_NAME)) { supers.add(superCld); supers.addAll(superCld.getAllSuperDescriptors()); } } return supers; } }
private static String getClassName(Class<?> cls, Model model) { if (cls != null) { ClassDescriptor cld = model.getClassDescriptorByName(cls.getName()); if (cld != null && !cld.isInterface()) { return cld.getName(); } } return ""; }
private static String getClassName(Class<?> cls, Model model) { if (cls != null) { ClassDescriptor cld = model.getClassDescriptorByName(cls.getName()); if (cld != null && !cld.isInterface()) { return cld.getName(); } } return ""; }
/** * Delete a tag by name from a class-descriptor. * * @param tagName The tag to remove. * @param cd The class descriptor to remove it from. * @param profile The profile the tag should be removed from. */ public void deleteTag(String tagName, ClassDescriptor cd, Profile profile) { deleteTag(tagName, cd.getName(), TagTypes.CLASS, profile.getUsername()); if (TagNames.IM_PUBLIC.equals(tagName)) { profile.invalidateTemplateCacheIfRequired(); } }
public void testGetClassDescriptorsForClass() throws Exception { Model model = Model.getInstanceByName("basicmodel"); Set<ClassDescriptor> cds = model.getClassDescriptorsForClass(org.intermine.model.basicmodel.Employee.class); Set<String> expectedCdNames = new HashSet<String>(); expectedCdNames.add("org.intermine.model.basicmodel.Employee"); Set<String> cdNames = new HashSet<String>(); for (ClassDescriptor cd: cds) { cdNames.add(cd.getName()); } assertEquals(expectedCdNames, cdNames); }
public void testInterfaceNotImplemented() throws MetaDataException { ClassDescriptor cld1 = makeInterface("package.name.Interface1"); Model model = new Model("model", "package.name", Collections.singleton(cld1)); assertTrue(model.getClassDescriptorByName(cld1.getName()).getSubDescriptors().size() == 0); }