Java 类org.apache.commons.collections.list.SetUniqueList 实例源码

项目:tibco-bwmaven    文件:ArchiveBuilder.java   
@SuppressWarnings("unchecked") // TODO: switch to Apache Commons 4.0+
public void removeDuplicateProcesses() {
    ElementNSImpl mergedEnterpriseArchive = (ElementNSImpl) this.repository.getAny().get(0);
    ElementNSImpl mergedProcessArchive = getElement(mergedEnterpriseArchive, "processArchive");
    ElementNSImpl mergedProcessProperty = getElement(mergedProcessArchive, "processProperty");

    String content = mergedProcessProperty.getTextContent();
    if (content != null && !content.isEmpty()) {
        List<String> processes = SetUniqueList.decorate(new ArrayList<String>());
        processes.addAll(Arrays.asList(content.split(",")));
        String contentWithoutDuplicate = StringUtils.join(processes, ",");
        mergedProcessProperty.setTextContent(contentWithoutDuplicate);
    }

}
项目:oStorybook    文件:PrefUtil.java   
public static void setDbFileList(List<DbFile> list) {
    PreferenceModel model = SbApp.getInstance().getPreferenceModel();
    Session session = model.beginTransaction();
    PreferenceDAOImpl dao = new PreferenceDAOImpl(session);
    @SuppressWarnings("unchecked")
    List<DbFile> uniqueList = (List<DbFile>) SetUniqueList.decorate(list);
    try {
        if (uniqueList.size() > 10) {
            uniqueList = uniqueList.subList(uniqueList.size() - 10,
                    uniqueList.size());
        }
    } catch (IndexOutOfBoundsException e) {
        // ignore
    }
    String val = StringUtils.join(uniqueList, "#");
    dao.saveOrUpdate(PreferenceKey.RECENT_FILES.toString(), val);
    model.commit();
}
项目:SE-410-Project    文件:PrefUtil.java   
public static void setDbFileList(List<DbFile> list) {
    PreferenceModel model = SbApp.getInstance().getPreferenceModel();
    Session session = model.beginTransaction();
    PreferenceDAOImpl dao = new PreferenceDAOImpl(session);
    @SuppressWarnings("unchecked")
    List<DbFile> uniqueList = (List<DbFile>) SetUniqueList.decorate(list);
    try {
        if (uniqueList.size() > 10) {
            uniqueList = uniqueList.subList(uniqueList.size() - 10,
                    uniqueList.size());
        }
    } catch (IndexOutOfBoundsException e) {
        // ignore
    }
    String val = StringUtils.join(uniqueList, "#");
    dao.saveOrUpdate(PreferenceKey.RECENT_FILES.toString(), val);
    model.commit();
}
项目:ga    文件:Team.java   
@Override
public Team createRandomIndividual() {
    Map<Position, Player> teamPlayers;
    do {
        teamPlayers = new LinkedHashMap<>();
        SetUniqueList uniq = SetUniqueList.decorate(new ArrayList<>());
        Player player;
        for (Position p : Position.values()) {
            while (! uniq.add(player = Player.getRandomPlayer(p.role))) {}
            teamPlayers.put(p, player);
        }
    } while (!TeamValidator.validate(teamPlayers));
    return new Team(teamPlayers);
}
项目:ga    文件:Team.java   
@Override
public Team createIndividual(Team t, int genIdx) {
    Map<Position, Player> teamPlayers;
    int tries = 100;
    boolean valid = false;
    do {                
        SetUniqueList uniq = SetUniqueList.decorate(new ArrayList<>());
        for (Player pl : t) {
            uniq.add(pl);
        }
        teamPlayers = new LinkedHashMap<>();
        Position pos;
        Player player;
        Iterator<Player> i = t.iterator();
        int j = 0;
        for (Iterator<Position> positions = Arrays.asList(Position.values()).iterator(); 
             j < t.size(); j++) {
            pos = positions.next();
            if (genIdx == j) {
                i.next();
                while (! uniq.add(player = Player.getRandomPlayer(pos.role))) {}
            } else {
                player = i.next();
            }
            teamPlayers.put(pos, player);
        }
    } while (!(valid = TeamValidator.validate(teamPlayers)) && (0 < --tries));
    return valid ? new Team(teamPlayers) : null;
}
项目:PersonaExtraction    文件:Persona.java   
@SuppressWarnings("unchecked")
public Persona() {
  this.pageId = null;
  this.hostPatternKey = null;
  this.usernames = (List<String>)SetUniqueList.decorate(new ArrayList<String>());
}
项目:caarray    文件:ArrayDaoImpl.java   
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings({"unchecked", "PMD.ExcessiveMethodLength", "PMD.NPathComplexity" })
public List<QuantitationType> searchForQuantitationTypes(PageSortParams<QuantitationType> params,
        QuantitationTypeSearchCriteria criteria) {
    final Criteria c = getCurrentSession().createCriteria(HybridizationData.class);
    c.createCriteria("hybridization").add(Restrictions.eq("id", criteria.getHybridization().getId()));
    c.createCriteria("dataSet").createAlias("quantitationTypes", "qt").createAlias("arrayData", "ad");
    c.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);

    if (!criteria.getArrayDataTypes().isEmpty()) {
        final List<Long> ids = new LinkedList<Long>();
        for (final ArrayDataType type : criteria.getArrayDataTypes()) {
            ids.add(type.getId());
        }
        c.createCriteria("ad.type").add(Restrictions.in("id", ids));
    }

    if (!criteria.getFileTypes().isEmpty() || !criteria.getFileCategories().isEmpty()) {
        c.createAlias("ad.dataFile", "df");
    }

    if (!criteria.getFileTypes().isEmpty()) {
        c.add(Restrictions.in("df.type",
                Sets.newHashSet(FileTypeRegistryImpl.namesForTypes(criteria.getFileTypes()))));
    }

    if (!criteria.getFileCategories().isEmpty()) {
        final Disjunction categoryCriterion = Restrictions.disjunction();
        if (criteria.getFileCategories().contains(FileCategory.DERIVED_DATA)) {
            categoryCriterion.add(Restrictions.in("df.type", Sets.newHashSet(FileTypeRegistryImpl
                    .namesForTypes(this.typeRegistry.getDerivedArrayDataTypes()))));
        }
        if (criteria.getFileCategories().contains(FileCategory.RAW_DATA)) {
            categoryCriterion.add(Restrictions.in("df.type",
                    Sets.newHashSet(FileTypeRegistryImpl.namesForTypes(this.typeRegistry.getRawArrayDataTypes()))));
        }
        c.add(categoryCriterion);
    }

    c.setFirstResult(params.getIndex());
    if (params.getPageSize() > 0) {
        c.setMaxResults(params.getPageSize());
    }
    c.addOrder(toOrder(params, "qt"));

    final List<Map<String, Object>> results = c.list();
    final List<QuantitationType> qTypes = SetUniqueList.decorate(new LinkedList<QuantitationType>());
    for (final Map<String, Object> row : results) {
        final QuantitationType qt = (QuantitationType) row.get("qt");
        qTypes.add(qt);
    }
    return qTypes;
}