001/*
002 * (C) Copyright 2006-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Thierry Delprat
016 */
017package org.nuxeo.apidoc.search;
018
019import org.nuxeo.apidoc.api.NuxeoArtifact;
020
021public class ArtifactWithWeight implements Comparable<ArtifactWithWeight> {
022
023    protected final NuxeoArtifact artifact;
024
025    protected int hits = 0;
026
027    public ArtifactWithWeight(NuxeoArtifact artifact) {
028        this.artifact = artifact;
029        hits = 1;
030    }
031
032    public NuxeoArtifact getArtifact() {
033        return artifact;
034    }
035
036    public int getHitNumbers() {
037        return hits;
038    }
039
040    public void addHit() {
041        hits += 1;
042    }
043
044    @Override
045    public int compareTo(ArtifactWithWeight other) {
046        return new Integer(hits).compareTo(new Integer(other.getHitNumbers()));
047    }
048
049}