Example usage for com.google.common.collect Maps newTreeMap

List of usage examples for com.google.common.collect Maps newTreeMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newTreeMap.

Prototype

public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() 

Source Link

Document

Creates a mutable, empty TreeMap instance using the natural ordering of its elements.

Usage

From source file:com.oddprints.dao.ApplicationSetting.java

public static Map<String, String> getSettings() {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    List<ApplicationSetting> applicationSettings = getSettingObjects(pm);

    Map<String, String> map = Maps.newTreeMap();
    for (ApplicationSetting setting : applicationSettings) {
        map.put(setting.getKey(), setting.getValue());
    }/*from   w w w  .j  a v a 2 s .  c o  m*/
    return map;
}

From source file:cuchaz.enigma.mapping.type.MethodMapping.java

public MethodMapping(MethodMapping other, ClassNameReplacer obfClassNameReplacer) {
    m_obfName = other.m_obfName;//  w  w  w. j  a  v a 2s  .  c o m
    m_deobfName = other.m_deobfName;
    m_obfSignature = new Signature(other.m_obfSignature, obfClassNameReplacer);
    m_arguments = Maps.newTreeMap();
    for (Entry<Integer, ArgumentMapping> entry : other.m_arguments.entrySet()) {
        m_arguments.put(entry.getKey(), new ArgumentMapping(entry.getValue()));
    }
}

From source file:org.codetrack.database.file.FileDatabase.java

private FileDatabase(Builder builder) {
    setLastUpdate(builder.lastUpdate);//w  w w. j a v a2s . c  o  m
    setName(builder.name);
    projectMap = Maps.newTreeMap();
    for (Project project : builder.projectMap.values())
        addProject(project);
}

From source file:org.apache.tajo.worker.TaskRunnerHistory.java

public TaskRunnerHistory(TaskRunnerHistoryProto proto) {
    this.state = Service.STATE.valueOf(proto.getState());
    this.containerId = TajoConverterUtils.toTajoContainerId(proto.getContainerId());
    this.startTime = proto.getStartTime();
    this.finishTime = proto.getFinishTime();
    this.executionBlockId = new ExecutionBlockId(proto.getExecutionBlockId());
    this.taskHistoryMap = Maps.newTreeMap();
    for (TaskHistoryProto taskHistoryProto : proto.getTaskHistoriesList()) {
        TaskHistory taskHistory = new TaskHistory(taskHistoryProto);
        taskHistoryMap.put(taskHistory.getTaskAttemptId(), taskHistory);
    }/*from  w  w  w .  ja  va 2 s.  co m*/
}

From source file:cuchaz.enigma.mapping.MethodMapping.java

public MethodMapping(MethodMapping other, Translator translator) {
    this.obfName = other.obfName;
    this.deobfName = other.deobfName;
    this.modifier = other.modifier;
    this.obfDescriptor = translator.getTranslatedMethodDesc(other.obfDescriptor);
    this.localVariables = Maps.newTreeMap();
    for (Map.Entry<Integer, LocalVariableMapping> entry : other.localVariables.entrySet()) {
        this.localVariables.put(entry.getKey(), new LocalVariableMapping(entry.getValue()));
    }/*from  w w w . j av a2s  .  com*/
}

From source file:org.apache.isis.core.metamodel.layout.DeweyOrderSet.java

public static DeweyOrderSet createOrderSet(final List<? extends IdentifiedHolder> identifiedHolders) {

    final SortedMap<String, SortedSet<IdentifiedHolder>> sortedMembersByGroup = Maps.newTreeMap();
    final SortedSet<IdentifiedHolder> nonAnnotatedGroup = Sets.newTreeSet(new MemberIdentifierComparator());

    // spin over all the members and put them into a Map of SortedSets
    // any non-annotated members go into additional nonAnnotatedGroup set.
    for (final IdentifiedHolder identifiedHolder : identifiedHolders) {
        final MemberOrderFacet memberOrder = identifiedHolder.getFacet(MemberOrderFacet.class);
        if (memberOrder == null) {
            nonAnnotatedGroup.add(identifiedHolder);
            continue;
        }/*from w w w  .  j  av  a 2s.c o  m*/
        final SortedSet<IdentifiedHolder> sortedMembersForGroup = getSortedSet(sortedMembersByGroup,
                memberOrder.name());
        sortedMembersForGroup.add(identifiedHolder);
    }

    // add the non-annotated group to the first "" group.
    final SortedSet<IdentifiedHolder> defaultSet = getSortedSet(sortedMembersByGroup, "");
    defaultSet.addAll(nonAnnotatedGroup);

    // create OrderSets, wiring up parents and children.

    // since sortedMembersByGroup is a SortedMap, the
    // iteration will be in alphabetical order (ie parent groups before
    // their children).
    final Set<String> groupNames = sortedMembersByGroup.keySet();
    final SortedMap<String, DeweyOrderSet> orderSetsByGroup = Maps.newTreeMap();

    for (final String string : groupNames) {
        final String groupName = string;
        final DeweyOrderSet deweyOrderSet = new DeweyOrderSet(groupName);
        orderSetsByGroup.put(groupName, deweyOrderSet);
        ensureParentFor(orderSetsByGroup, deweyOrderSet);
    }

    // now populate the OrderSets
    for (final String groupName : groupNames) {
        final DeweyOrderSet deweyOrderSet = orderSetsByGroup.get(groupName);
        // REVIEW: something fishy happens here with casting, hence warnings
        // left in
        final SortedSet sortedMembers = sortedMembersByGroup.get(groupName);
        deweyOrderSet.addAll(sortedMembers);
        deweyOrderSet.copyOverChildren();
    }

    return orderSetsByGroup.get("");
}

From source file:com.orange.clara.cloud.servicedbdumper.dbdumper.s3.UploadS3StreamImpl.java

@Override
public String upload(InputStream content, Blob blob) throws IOException {
    String key = blob.getMetadata().getName();
    ContentMetadata metadata = blob.getMetadata().getContentMetadata();
    ObjectMetadataBuilder builder = ObjectMetadataBuilder.create().key(key)
            .contentType(MediaType.OCTET_STREAM.toString()).contentDisposition(key)
            .contentEncoding(metadata.getContentEncoding()).contentLanguage(metadata.getContentLanguage())
            .userMetadata(blob.getMetadata().getUserMetadata());
    String uploadId = this.s3Client.initiateMultipartUpload(bucketName, builder.build());
    Integer partNum = 1;//from   ww w  .j  av a2  s.  com
    Payload part = null;
    int bytesRead = 0;
    boolean shouldContinue = true;
    try {
        SortedMap<Integer, String> etags = Maps.newTreeMap();
        while (shouldContinue) {
            byte[] chunk = new byte[CHUNK_SIZE];
            bytesRead = ByteStreams.read(content, chunk, 0, chunk.length);
            if (bytesRead != chunk.length) {
                shouldContinue = false;
                chunk = Arrays.copyOf(chunk, bytesRead);
            }
            part = new ByteArrayPayload(chunk);
            prepareUploadPart(bucketName, key, uploadId, partNum, part, etags);
            partNum++;
        }
        return this.s3Client.completeMultipartUpload(bucketName, key, uploadId, etags);
    } catch (RuntimeException ex) {
        this.s3Client.abortMultipartUpload(bucketName, key, uploadId);
        throw ex;
    }
}

From source file:cubicchunks.server.CubeWatcher.java

public CubeWatcher(Cube cube) {
    if (cube == null) {
        throw new IllegalArgumentException("cube cannot be null!");
    }//w ww .j a  v a  2s  .c o m

    this.cube = cube;
    this.players = Maps.newTreeMap();
    this.previousWorldTime = 0;
    this.dirtyBlocks = new TreeSet<Integer>();
}

From source file:com.google.caliper.model.VmSpec.java

private VmSpec() {
    this.properties = Maps.newTreeMap();
    this.options = Maps.newTreeMap();
}

From source file:com.cinchapi.concourse.server.storage.db.PrimaryRecord.java

/**
 * Return a log of revision to the entire Record.
 * //from   ww w  . j av  a2  s . com
 * @return the revision log
 */
public Map<Long, String> audit() {
    read.lock();
    try {
        Map<Long, String> audit = Maps.newTreeMap();
        for (Entry<Text, List<CompactRevision<Value>>> entry : history.entrySet()) {
            String key = entry.getKey().toString();
            for (CompactRevision<Value> revision : entry.getValue()) {
                audit.put(revision.getVersion(), revision.toString(locator, key));
            }
        }
        return audit;
    } finally {
        read.unlock();
    }
}