Example usage for java.util List hashCode

List of usage examples for java.util List hashCode

Introduction

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

Prototype

int hashCode();

Source Link

Document

Returns the hash code value for this list.

Usage

From source file:org.dawnsci.spectrum.ui.utils.SpectrumUtils.java

public static ISpectrumFile[] subtractSpectrumFiles(List<IContain1DData> files, IPlottingSystem<?> system) {

    //TODO deal with single files

    if (files.size() != 2)
        return null;

    if (files.get(0).getyDatasets().isEmpty() || files.get(1).getyDatasets().isEmpty())
        return null;

    files = getCompatibleDatasets(files);
    if (files == null)
        return null;

    IDataset x0 = files.get(0).getxDataset();
    IDataset x1 = files.get(1).getxDataset();

    if (!x0.equals(x1))
        return null;

    List<IDataset> sets1 = new ArrayList<IDataset>();
    List<IDataset> sets2 = new ArrayList<IDataset>();

    IDataset ds0 = files.get(0).getyDatasets().get(0);
    IDataset ds1 = files.get(1).getyDatasets().get(0);
    IDataset dif = Maths.subtract(ds0, ds1);
    IDataset dif1 = Maths.subtract(ds1, ds0);

    dif.setName("Difference");
    dif1.setName("Difference");
    sets1.add(dif);/*from  w  ww. ja  v  a  2s  .c o  m*/
    sets2.add(dif1);

    SpectrumInMemory[] out = new SpectrumInMemory[2];

    String first = "Difference: " + files.get(0).getName() + "-" + files.get(1).getName();
    String second = "Difference: " + files.get(1).getName() + "-" + files.get(0).getName();

    String firstLong = "Difference: " + files.get(0).getName() + ":"
            + files.get(0).getyDatasets().get(0).getName() + "\n-" + files.get(1).getName() + ":"
            + files.get(1).getyDatasets().get(0).getName() + "(" + sets1.hashCode() + ")";
    String secondLong = "Difference: " + files.get(1).getName() + ":"
            + files.get(1).getyDatasets().get(0).getName() + "\n-" + files.get(0).getName() + ":"
            + files.get(0).getyDatasets().get(0).getName() + "(" + sets1.hashCode() + ")";

    out[0] = new SpectrumInMemory(firstLong, first, x0, sets1, system);
    out[1] = new SpectrumInMemory(secondLong, second, x0, sets2, system);

    return out;

}

From source file:com.croer.services.ItembusqManagement.java

@Transactional
public void borraOrtograma(List<Ortograma> ortoList, Itembusq itembusq) {
    for (Ortograma ortograma : ortoList) {
        String tmpType = itembusq.getItembusqPK().getType();
        System.out.println("itemOrtogramaRepository " + itemOrtogramaRepository);
        System.out.println("Ortis " + ortograma);
        List<ItemOrtograma> tmp = itemOrtogramaRepository.findByOrtogramaAndType(ortograma.getOrtograma(),
                tmpType);/*  w w  w  .  ja v  a2  s  . com*/
        if (!tmp.isEmpty()) { //* Se usa para describir otros types?
            return;
        }

        List<DiccionarioOrtograma> dol = ortograma.getDiccionarioOrtogramaList();
        dol.remove(new DiccionarioOrtograma(tmpType, ortograma.getOrtograma())); //* Borra del diccionario de Productos
        if (dol.size() > 0) { //* Se usa en otros diccionarios?  
            ortogramaRepository.save(ortograma); //* Actualiza BD
            return;
        }

        //Dame sus simigramas asociados (va sus alineaciones) 
        List<Alineacion> alinList = ortograma.getAlineacionList();
        List<Simigrama> simiList = new ArrayList<>();
        for (Alineacion alineacion : alinList) {
            simiList.add(alineacion.getSimigrama1());
        }

        //Borra las alineaciones del ortograma a borrar, y en su caso el simigrama 
        for (Simigrama simigrama : simiList) {
            List<Alineacion> alinListT = simigrama.getAlineacionList();
            System.out.println("D " + simigrama.getSimigrama() + ":" + alinListT);
            System.out.println("MemEAM " + simigrama.hashCode() + ':' + alinListT.hashCode());

            Alineacion t = new Alineacion(simigrama.getSimigrama(), ortograma.getOrtograma());
            alinListT.remove(t); //* Borra las Alineacion(es) del ortograma
            if (alinListT.isEmpty()) {
                System.out.println("Borrando simigrama " + simigrama.getSimigrama() + ":" + alinListT);
                simigramaRepository.delete(simigrama); //* Borra Simigrama y todas sus Alineacion(es)
            } else {
                System.out.println("Dejando simigrama " + simigrama.getSimigrama() + ":" + alinListT);
                simigramaRepository.save(simigrama); //* Solo conserva las alineaciones de los otros ortogramas 
            }
        }

        ortogramaRepository.delete(ortograma); //* Borra el ortograma y sus DiccOrto
    }
}

From source file:org.maodian.flyingcat.xmpp.codec.RosterCodec.java

@Override
@Transactional(readOnly = true)/*from   w w w.  j ava 2 s . co m*/
public Object processGet(XmppContext context, InfoQuery iq) {
    IMSession session = context.getIMSession();
    // null means get profile of current user
    Collection<ContactEntity> imContacts = session.getAccountRepository()
            .findByUid(context.getJabberID().getUid()).getContacts();
    List<Contact> xmppContacts = new ArrayList<>();
    for (ContactEntity ce : imContacts) {
        Contact c = new Contact(ce.getUid(), ce.getRelationship().name().toLowerCase());
        c.setName(ce.getNick());
        xmppContacts.add(c);
    }

    return new Roster(xmppContacts.hashCode() + "", xmppContacts.toArray(new Contact[0]));
}

From source file:org.commonjava.atlas.maven.graph.model.EProjectCycle.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;

    final List<ProjectRelationship<?, ?>> sorted = new ArrayList<ProjectRelationship<?, ?>>(relationships);
    Collections.sort(sorted, RelationshipComparator.INSTANCE);

    result = prime * result + sorted.hashCode();
    return result;
}

From source file:org.androidaalto.droidkino.activities.DroidkinoMain.java

/**
 * @param movieList the movie list to use for the new fragment
 *//*from   w  ww  . j a v  a2 s  .  c  o  m*/
private void publishList(List<MovieInfo> movieList) {
    MovieListFragment movieListFragment = (MovieListFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragment_container);
    if (movieListFragment == null || movieListFragment.getCurrentMovieListHashCode() != movieList.hashCode()) {
        Log.d(LOG_TAG, "Creating movie list fragment with " + movieList.size() + " elements");

        // Make new fragment to show the movie list.
        movieListFragment = MovieListFragment.newInstance(movieList);

        // Execute a transaction, replacing any existing fragment
        // with this one inside the frame.
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.fragment_container, movieListFragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.commit();
    }
}

From source file:org.apache.tez.dag.api.client.DAGStatus.java

@Override
public int hashCode() {
    // Source explicitly exclude from hashCode
    final int prime = 44017;
    int result = 1;
    result = prime + getState().hashCode();

    List<String> diagnostics = getDiagnostics();
    Progress dagProgress = getDAGProgress();
    Map<String, Progress> vProgress = getVertexProgress();
    TezCounters counters = getDAGCounters();

    result = prime * result + ((diagnostics == null) ? 0 : diagnostics.hashCode());
    result = prime * result + ((dagProgress == null) ? 0 : dagProgress.hashCode());
    result = prime * result + ((vProgress == null) ? 0 : vProgress.hashCode());
    result = prime * result + ((counters == null) ? 0 : counters.hashCode());

    return result;
}

From source file:rest.FlightService.java

/**
 * Returns flights from Just Fly (our) company.
 *
 * Returns flights from a given origin but without destination.
 *
 * @param request/*from   ww  w  .j  a v  a  2  s  . c o m*/
 * @Author: Casper Schultz
 * @Date: 2/12 2015
 *
 * @param from Travel Origin as IATA code
 * @param day Day as date string formatted as: 2016-02-25
 * @param seats Number of seats required
 * @return Json object with flights that match the criteria.
 * @throws FlightException
 */
@GET
@Path("flightinfo/{from}/{day}/{seats}")
@Produces(MediaType.APPLICATION_JSON)
public Response getFlightsFrom(@PathParam("from") String from, @PathParam("day") String day,
        @PathParam("seats") int seats, @Context Request request) throws FlightException {

    // We validate the input data, to make sure its a valid IATA code
    // and that the date has been formatted correctly
    if (!NorweigianDestinations.validDestination(from)) {
        throw new FlightException("We do not support flights to the given IATA destination",
                Response.Status.NO_CONTENT, 1);
    }

    // Fetch the flights
    List<Flight> flights = facade.getJFFlightsFrom(from, day, seats);

    // Add some caching
    CacheControl cc = new CacheControl();
    cc.setMaxAge(86400);
    EntityTag etag = new EntityTag(Integer.toString(flights.hashCode()));
    ResponseBuilder builder = request.evaluatePreconditions(etag);

    // cached resource did change -> serve updated content
    if (builder == null) {
        builder = Response.ok(buildJsonObject(flights, seats));
        builder.tag(etag);
    }

    builder.cacheControl(cc);
    return builder.build();
}

From source file:rest.FlightService.java

/**
 * Returns flights from Just Fly (our) company.
 *
 * @param request/*from  ww  w  .j a v  a2 s .com*/
 * @Author: Casper Schultz
 * @Date: 2/12 2015
 *
 * @param from Travel Origin as IATA code
 * @param to Travel destination as IATA code
 * @param day Day as date string formatted as: 2016-02-25
 * @param seats Number of seats required
 * @return Json object with flights that match the criteria.
 * @throws FlightException
 */
@GET
@Path("flightinfo/{from}/{to}/{day}/{seats}")
@Produces(MediaType.APPLICATION_JSON)
public Response getFlightsToFrom(@PathParam("from") String from, @PathParam("to") String to,
        @PathParam("day") String day, @PathParam("seats") int seats, @Context Request request)
        throws FlightException {

    // We validate the input data, to make sure its a valid IATA code
    // and that the date has been formatted correctly
    if (!NorweigianDestinations.validDestination(from) || !NorweigianDestinations.validDestination(to)) {
        throw new FlightException("We do not support flights to the given IATA destination",
                Response.Status.NO_CONTENT, 1);
    }

    // Fetch the flights
    List<Flight> flights = facade.getJFFlights(from, to, day, seats);

    // Add some caching
    CacheControl cc = new CacheControl();
    cc.setMaxAge(86400);
    EntityTag etag = new EntityTag(Integer.toString(flights.hashCode()));
    ResponseBuilder builder = request.evaluatePreconditions(etag);

    if (builder == null) {
        builder = Response.ok(buildJsonObject(flights, seats));
        builder.tag(etag);
    }

    builder.cacheControl(cc);
    return builder.build();
}

From source file:org.caleydo.neo4j.plugins.kshortestpaths.KShortestPathsAlgo.java

private int generatePathHash(WeightedPath path) {
    List<Long> idList = new ArrayList<Long>((path.length() * 2) + 1);
    for (Node n : path.nodes()) {
        idList.add(n.getId());/*www.ja  va2 s .  co m*/
    }
    for (Relationship r : path.relationships()) {
        idList.add(r.getId());
    }

    return idList.hashCode();
}

From source file:org.dawnsci.spectrum.ui.processing.AverageProcess.java

@Override
public List<IContain1DData> process(List<IContain1DData> list) {

    list = SpectrumUtils.getCompatibleDatasets(list);

    if (list == null)
        return null;

    IDataset x0 = list.get(0).getxDataset();

    StringBuilder sb = new StringBuilder();
    sb.append("Average of: ");
    sb.append("\n");
    MultivariateSummaryStatistics ms = new MultivariateSummaryStatistics(x0.getSize(), false);
    for (IContain1DData file : list) {

        sb.append(file.getName() + ":");

        for (IDataset ds : file.getyDatasets()) {

            sb.append(ds.getName() + ":");

            DoubleDataset dd;/*from  w w w. j  a v  a2  s . co m*/
            if (ds instanceof DoubleDataset)
                dd = (DoubleDataset) ds;
            else {
                dd = (DoubleDataset) DatasetUtils.cast(ds, Dataset.FLOAT64);
            }
            double[] raw = dd.getData();
            ms.addValue(raw);
        }

        sb.deleteCharAt(sb.length() - 1);
        sb.deleteCharAt(sb.length() - 1);
        sb.append("\n");
    }
    List<IDataset> sets = new ArrayList<IDataset>();
    Dataset dd = DatasetFactory.createFromObject(ms.getMean());

    dd.setName("Average");
    sets.add(dd);

    String shortName = "Average: " + list.get(0).getName() + " to " + list.get(list.size() - 1).getName();

    return Arrays.asList(new IContain1DData[] {
            new Contain1DDataImpl(x0, sets, shortName, sb.toString() + "[" + sets.hashCode() + "]") });

}