/** * This method will return the first Alias having this typeId/type name * It will return null if there are no Alias with this type id/name * @param aliases : the collection of Alias * @param typeId : the type id to look for * @param typeName : the type name to look for * @param name: alias name * @return the first alias having this type name/id, null if no Alias with this type name/id */ public static Alias collectFirstAliasWithTypeAndName(Collection<? extends Alias> aliases, String typeId, String typeName, String name){ if (aliases == null || aliases.isEmpty()){ return null; } for (Alias alias : aliases){ if (doesAliasHaveTypeAndName(alias, typeId, typeName, name)){ return alias; } } return null; }
/** * Remove all Alias having this method name/method id from the collection of aliases * @param aliases : the collection of Checksum * @param typeId : the method id to look for * @param typeName : the method name to look for * @param name: alias name */ public static void removeAllAliasesWithTypeAndName(Collection<Alias> aliases, String typeId, String typeName, String name){ if (aliases != null){ Iterator<Alias> aliasIterator = aliases.iterator(); while (aliasIterator.hasNext()){ if (doesAliasHaveTypeAndName(aliasIterator.next(), typeId, typeName, name)){ aliasIterator.remove(); } } } }
/** * Extract all the aliases having a specific type. * @param aliases : : the aliases to analyse * @param typeId : : the alias type MI identifier * @param typeName : : the alias type name * @param name: alias name * @return the selection of aliases having the specified type (typeId or typeName if no ids) */ public static Collection<Alias> collectAllAliasesHavingTypeAndName(Collection<? extends Alias> aliases, String typeId, String typeName, String name){ if (aliases == null || aliases.isEmpty()){ return Collections.EMPTY_LIST; } Collection<Alias> selectedAliases = new ArrayList<Alias>(aliases.size()); for (Alias alias : aliases){ if (doesAliasHaveTypeAndName(alias, typeId, typeName, name)){ selectedAliases.add(alias); } } return selectedAliases; }