Example usage for java.util LinkedHashSet LinkedHashSet

List of usage examples for java.util LinkedHashSet LinkedHashSet

Introduction

In this page you can find the example usage for java.util LinkedHashSet LinkedHashSet.

Prototype

public LinkedHashSet() 

Source Link

Document

Constructs a new, empty linked hash set with the default initial capacity (16) and load factor (0.75).

Usage

From source file:br.ufpa.gercom.mtuldp.store.HostStorageMgm.java

public boolean create(Host host) throws RuntimeException {

    checkNotNull(host, "Host Object cannot be null");

    String CREATE = "MERGE" + "(a:%s" + "{" + "id:'%s', " + "host_id:'%s'," + "mac:'%s'," + "ip:%s,"
            + "vlan:'%s'" + "})";

    String id = getId(host);/*from   w w w  .j a  v  a 2 s . c  o m*/
    String type = Host.class.getSimpleName();
    String host_id = host.id().toString();
    String mac = host.mac().toString();
    String vlan = host.vlan().toString();
    Set<String> ip = new LinkedHashSet<>();

    host.ipAddresses().forEach(ipAddress -> {
        ip.add("\'" + ipAddress.toString() + "\'");
    });

    String query = String.format(CREATE, type, host_id, mac, ip.toString(), vlan);

    StatementResult result = driver.executeCypherQuery(query);
    ResultSummary summary = result.consume();

    if (summary.counters().nodesCreated() == 0) {
        log.error("Host id ({}) cannot be create by host already exists or error transaction", host_id);
        return false;
    }

    log.info("Host id ({}) had created with sucessfully", host_id);
    return true;
}

From source file:org.eclipse.virgo.ide.jdt.internal.ui.actions.EnableServerClasspathContainerActionDelegate.java

public void run(IAction action) {
    Set<IJavaProject> projects = new LinkedHashSet<IJavaProject>();
    Iterator<IProject> iter = selected.iterator();
    while (iter.hasNext()) {
        IProject project = iter.next();//from  w  ww  .  j a v  a2  s. c  o  m
        if (FacetUtils.isBundleProject(project)) {
            projects.add(JdtUtils.getJavaProject(project));
        } else if (FacetUtils.isParProject(project)) {
            for (IProject bundle : FacetUtils.getBundleProjects(project)) {
                projects.add(JdtUtils.getJavaProject(bundle));
            }
        }
    }

    for (IJavaProject javaProject : projects) {
        try {
            if (ClasspathUtils.hasClasspathContainer(javaProject)) {
                removeFromClasspath(javaProject,
                        JavaCore.newContainerEntry(ServerClasspathContainer.CLASSPATH_CONTAINER_PATH, null,
                                ServerClasspathContainer.CLASSPATH_CONTAINER_ATTRIBUTE, false),
                        new NullProgressMonitor());
                // Remove any error markers that might hang around
                javaProject.getProject().deleteMarkers(JdtCorePlugin.DEPENDENCY_PROBLEM_MARKER_ID, true,
                        IResource.DEPTH_INFINITE);
            } else {
                addToClasspath(javaProject,
                        JavaCore.newContainerEntry(ServerClasspathContainer.CLASSPATH_CONTAINER_PATH, null,
                                ServerClasspathContainer.CLASSPATH_CONTAINER_ATTRIBUTE, false),
                        new NullProgressMonitor());
            }
        } catch (CoreException e) {
            JdtCorePlugin.log(e);
        }
    }

}

From source file:cc.gospy.example.google.GoogleSpider.java

public Collection<String> getResultLinks(final String keyword, final int pageFrom, final int pageTo) {
    if (pageFrom < 1)
        throw new IllegalArgumentException(pageFrom + "<" + 1);
    if (pageFrom >= pageTo)
        throw new IllegalArgumentException(pageFrom + ">=" + pageTo);

    final AtomicInteger currentPage = new AtomicInteger(pageFrom);
    final AtomicBoolean returned = new AtomicBoolean(false);
    final Collection<String> links = new LinkedHashSet<>();
    Gospy googleSpider = Gospy.custom()// w w w  . ja  v a2 s .c  o  m
            .setScheduler(
                    Schedulers.VerifiableScheduler.custom().setExitCallback(() -> returned.set(true)).build())
            .addFetcher(Fetchers.HttpFetcher.custom()
                    .before(request -> request.setConfig(
                            RequestConfig.custom().setProxy(new HttpHost("127.0.0.1", 8118)).build()))
                    .build())
            .addProcessor(Processors.XPathProcessor.custom()
                    .extract("//*[@id='ires']/ol/div/h3/a/@href", (task, resultList, returnedData) -> {
                        resultList.forEach(a -> {
                            if (a.startsWith("/url?q=")) {
                                String link = a.substring(7);
                                int end = link.indexOf("&sa=");
                                links.add(link.substring(0, end != -1 ? end : link.length()));
                            }
                        });
                        currentPage.incrementAndGet();
                        if (pageFrom <= currentPage.get() && currentPage.get() < pageTo) {
                            return Arrays.asList(
                                    new Task(String.format("http://www.google.com/search?q=%s&start=%d&*",
                                            keyword, (currentPage.get() - 1) * 10)));
                        } else {
                            return Arrays.asList();
                        }
                    }).build())
            .build().addTask(String.format("http://www.google.com/search?q=%s&start=%d&*", keyword, pageFrom));
    googleSpider.start();
    while (!returned.get())
        ; // block until spider returned
    googleSpider.stop();
    return links;
}

From source file:cc.gospy.example.google.GoogleScholarSpider.java

public Collection<String> getResultLinks(final String keyword, final int pageFrom, final int pageTo) {
    if (pageFrom < 1)
        throw new IllegalArgumentException(pageFrom + "<" + 1);
    if (pageFrom >= pageTo)
        throw new IllegalArgumentException(pageFrom + ">=" + pageTo);

    final AtomicInteger currentPage = new AtomicInteger(pageFrom);
    final AtomicBoolean returned = new AtomicBoolean(false);
    final Collection<String> links = new LinkedHashSet<>();
    Gospy googleScholarSpider = Gospy.custom()
            .setScheduler(/*from   w  w  w  . j a va2s .c om*/
                    Schedulers.VerifiableScheduler.custom().setExitCallback(() -> returned.set(true)).build())
            .addFetcher(Fetchers.HttpFetcher.custom()
                    .before(request -> request.setConfig(
                            RequestConfig.custom().setProxy(new HttpHost("127.0.0.1", 8118)).build()))
                    .build())
            .addProcessor(Processors.XPathProcessor.custom().extract(
                    "//*[@id='gs_ccl_results']/div/div/h3/a/@href", (task, resultList, returnedData) -> {
                        links.addAll(resultList);
                        currentPage.incrementAndGet();
                        if (pageFrom <= currentPage.get() && currentPage.get() < pageTo) {
                            return Arrays.asList(
                                    new Task(String.format("https://scholar.google.com/scholar?start=%d&q=%s",
                                            (currentPage.get() - 1) * 10, keyword)));
                        } else {
                            return Arrays.asList();
                        }
                    }).build())
            .build()
            .addTask(String.format("https://scholar.google.com/scholar?start=%d&q=%s", pageFrom, keyword));
    googleScholarSpider.start();
    while (!returned.get())
        ; // block until spider returned
    googleScholarSpider.stop();
    return links;
}

From source file:com.eventsourcing.index.NavigableIndexTest.java

public static <A> Set<A> setOf(Iterable<A> values) {
    Set<A> result = new LinkedHashSet<>();
    for (A value : values) {
        result.add(value);// w w w.j a va  2 s  .  c o m
    }
    return result;
}

From source file:de.vandermeer.skb.interfaces.messagesets.IsWarningSet.java

/**
 * Creates a new warning set.//  w  ww . j a  v a2 s .  c om
 * @param <M> type of the messages in the set
 * @return new warning set
 */
static <M> IsWarningSet<M> create() {
    return new IsWarningSet<M>() {
        final Set<M> warningSet = new LinkedHashSet<>();

        @Override
        public Set<M> getWarningMessages() {
            return this.warningSet;
        }
    };
}

From source file:com.genentech.application.calcProps.SDFCalcProps.java

/** 
 * Get a list of calculators based on the property requested by the user
 * //from   w w  w .ja va 2  s.  c o m
 * getCalculators() calls itself in case the requiredCalculator list is not
 * empty.
 * 
 * @param prop
 *           Name of the requested properties
 * @param availCALCS
 *           is the full list of calculators defined by the XML files
 * @return  a set of calculators 
 */
private static Set<Calculator> getCalculators(String prop, Set<Calculator> availCALCS) {
    Set<Calculator> myCalcs = new LinkedHashSet<Calculator>();
    for (Calculator calc : availCALCS) {
        if (calc.getName().equals(prop)) {
            myCalcs.add(calc);
            for (String dep : calc.getRequiredCalculators()) {
                //recursively get all dependent calculators
                myCalcs.addAll(getCalculators(dep, availCALCS));
            }
        }
    }
    return myCalcs;
}

From source file:gr.abiss.calipso.domain.SpaceRole.java

public SpaceRole(long id, Space space, String description, RoleType roleType) {
    this.id = id;
    this.space = space;
    this.description = description;
    this.roleTypeId = roleType.getId();
    this.roleCode = createRoleCode();
    this.userSpaceRoles = new LinkedHashSet<UserSpaceRole>();
    this.roleSpaceStdFields = new LinkedHashSet<RoleSpaceStdField>();
}

From source file:com.qmetry.qaf.automation.step.JavaStepFinder.java

public static Map<String, TestStep> getAllJavaSteps() {
    Map<String, TestStep> stepMapping = new HashMap<String, TestStep>();
    Set<Method> steps = new LinkedHashSet<Method>();

    List<String> pkgs = new ArrayList<String>();
    pkgs.add(STEPS_PACKAGE);//from  w  w w. j av a  2  s  .  c o m

    if (getBundle().containsKey(STEP_PROVIDER_PKG.key)) {
        pkgs.addAll(Arrays.asList(getBundle().getStringArray(STEP_PROVIDER_PKG.key)));
    }
    for (String pkg : pkgs) {
        logger.info("pkg: " + pkg);
        try {
            List<Class<?>> classes = CLASS_FINDER.getClasses(pkg);
            steps.addAll(getAllMethodsWithAnnotation(classes, QAFTestStep.class));
        } catch (Exception e) {
            System.err.println("Unable to load steps for package: " + pkg);
        }
    }

    for (Method step : steps) {
        if (!Modifier.isPrivate(step.getModifiers())) {
            // exclude private methods.
            // Case: step provided using QAFTestStepProvider at class level
            add(stepMapping, new JavaStep(step));
        }
    }

    return stepMapping;

}

From source file:com.sshdemo.common.report.manage.service.TextReportService.java

@Override
public Long addTextReport(TextReport textReport) throws BaseException {
    byte[] reportFile = textReport.getTextEntity();

    if (reportFile != null && reportFile.length > 0) {
        InputStream in = new ByteArrayInputStream(reportFile);
        TextDesignUtil rd = new TextDesignUtil(in);
        List<JRParameter> paramList = rd.getParameters();

        Set<Parameter> icSet = new LinkedHashSet<Parameter>();
        if (!paramList.isEmpty()) {
            for (JRParameter param : paramList) {
                Parameter ic = getParameterValue(param);
                icSet.add(ic);/* ww w  .j  a  v  a 2s  . c om*/
            }
            textReport.setParameters(icSet);
        }
    }
    textReportDAO.persist(textReport);
    return textReport.getId();
}