Example usage for com.google.common.collect ImmutableMap keySet

List of usage examples for com.google.common.collect ImmutableMap keySet

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMap keySet.

Prototype

public ImmutableSet<K> keySet() 

Source Link

Usage

From source file:org.flockdata.search.service.ContentService.java

public ContentStructure getStructure(QueryParams queryParams) throws FlockException {
    try {/* w  w w . j  a  va2s.  co  m*/
        String[] indexes = indexManager.getIndexesToQuery(queryParams);
        GetFieldMappingsRequestBuilder fieldMappings = elasticSearchClient.admin().indices()
                .prepareGetFieldMappings(indexes);
        fieldMappings.setFields("data.*", "tag.*", "e.*", "up.*", SearchSchema.PROPS, SearchSchema.CREATED,
                SearchSchema.UPDATED, SearchSchema.DOC_TYPE);
        ListenableActionFuture<GetFieldMappingsResponse> future = fieldMappings.execute();
        GetFieldMappingsResponse result = future.get();
        ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, GetFieldMappingsResponse.FieldMappingMetaData>>> mappings = result
                .mappings();
        for (String index : mappings.keySet()) {
            ImmutableMap<String, ImmutableMap<String, GetFieldMappingsResponse.FieldMappingMetaData>> stringImmutableMapImmutableMap = mappings
                    .get(index);
            for (String type : stringImmutableMapImmutableMap.keySet()) {
                ContentStructure contentStructure = new ContentStructure(index, type);
                ImmutableMap<String, GetFieldMappingsResponse.FieldMappingMetaData> fields = stringImmutableMapImmutableMap
                        .get(type);
                for (String field : fields.keySet()) {
                    handle(contentStructure, fields.get(field));
                }
                return contentStructure;
            }
        }
        //            logger.info(result.toString());
        return null;
    } catch (FlockException e) {
        logger.error(e.getMessage());
        throw (e);
    } catch (InterruptedException | ExecutionException e) {
        logger.error(e.getMessage());
        throw new FlockException(e.getMessage());
    }
}

From source file:de.adrodoc55.minecraft.mpl.conversion.StructureConverter.java

public TagCompound convert(MplCompilationResult result) {
    states.clear();/*  w ww.  j av  a  2 s . c  om*/
    ImmutableMap<Coordinate3D, MplBlock> blockMap = result.getBlocks();
    ImmutableSet<Coordinate3D> coordinates = blockMap.keySet();
    Coordinate3D min = getMinCoordinate(coordinates);
    Coordinate3D max = getMaxCoordinate(coordinates);

    List<ITag> blocks = new ArrayList<>();
    for (int y = min.getY(); y <= max.getY(); y++) {
        for (int z = min.getZ(); z <= max.getZ(); z++) {
            for (int x = min.getX(); x <= max.getX(); x++) {
                Coordinate3D coord = new Coordinate3D(x, y, z);
                MplBlock block = blockMap.get(coord);
                if (block == null) {
                    block = new AirBlock(coord);
                }

                TagCompound tag = new TagCompound("");
                tag.setTag(new TagInteger("state", registerState(block)));
                tag.setTag(new TagList("pos", posAt(x, y, z)));

                if (block instanceof CommandBlock) {
                    TagCompound nbt = toControl((CommandBlock) block);
                    nbt.setName("nbt");
                    tag.setTag(nbt);
                }
                blocks.add(tag);
            }
        }
    }
    short sizeX = (short) (1 + max.getX() - min.getX());
    short sizeY = (short) (1 + max.getY() - min.getY());
    short sizeZ = (short) (1 + max.getZ() - min.getZ());
    List<ITag> palette = states.stream().map(s -> s.getState()).collect(toList());

    TagCompound structure = new TagCompound("");
    structure.setTag(new TagInteger("version", 1));
    structure.setTag(new TagString("author", "MPL"));
    structure.setTag(new TagList("blocks", blocks));
    structure.setTag(new TagList("entities", new ArrayList<>()));
    structure.setTag(new TagList("palette", palette));
    structure.setTag(new TagList("size", posAt(sizeX, sizeY, sizeZ)));

    return structure;
}

From source file:org.apache.flume.plugins.KafkaSource.java

@Override
public void configure(Context context) {
    this.context = context;
    ImmutableMap<String, String> props = context.getParameters();

    // base: consumer.sources.s
    this.parameters = new Properties();
    for (String key : props.keySet()) {
        String value = props.get(key);
        this.parameters.put(key, value);
    }/*from www. j a  v a 2s .  c o m*/

    //source monitoring count
    if (sourceCounter == null) {
        sourceCounter = new SourceCounter(getName());
    }
}

From source file:esun.org.apache.flume.plugins.KafkaSource.java

/**
 * Configure void.//from  w  w  w  .j  a  v a2s . c  om
 *
 * @param context the context
 */
@Override
public void configure(Context context) {
    this.context = context;
    ImmutableMap<String, String> props = context.getParameters();

    this.parameters = new Properties();
    for (String key : props.keySet()) {
        String value = props.get(key);
        this.parameters.put(key, value);
    }

    //source monitoring count
    if (sourceCounter == null) {
        sourceCounter = new SourceCounter(getName());
    }
}

From source file:com.facebook.buck.apple.AbstractProvisioningProfileMetadata.java

public ImmutableMap<String, NSObject> getMergeableEntitlements() {
    final ImmutableSet<String> excludedKeys = ImmutableSet.of(
            "com.apple.developer.icloud-container-development-container-identifiers",
            "com.apple.developer.icloud-container-environment",
            "com.apple.developer.icloud-container-identifiers", "com.apple.developer.icloud-services",
            "com.apple.developer.restricted-resource-mode",
            "com.apple.developer.ubiquity-container-identifiers",
            "com.apple.developer.ubiquity-kvstore-identifier", "inter-app-audio", "com.apple.developer.homekit",
            "com.apple.developer.healthkit", "com.apple.developer.in-app-payments", "com.apple.developer.maps",
            "com.apple.external-accessory.wireless-configuration");

    ImmutableMap<String, NSObject> allEntitlements = getEntitlements();
    ImmutableMap.Builder<String, NSObject> filteredEntitlementsBuilder = ImmutableMap.builder();
    for (String key : allEntitlements.keySet()) {
        if (!excludedKeys.contains(key)) {
            filteredEntitlementsBuilder.put(key, allEntitlements.get(key));
        }//from  w ww .j av a2  s .  c o  m
    }
    return filteredEntitlementsBuilder.build();
}

From source file:com.facebook.presto.connector.jmx.JmxRecordSetProvider.java

@Override
public RecordSet getRecordSet(ConnectorSession session, ConnectorSplit split,
        List<? extends ColumnHandle> columns) {
    JmxTableHandle tableHandle = checkType(split, JmxSplit.class, "split").getTableHandle();

    requireNonNull(columns, "columns is null");
    checkArgument(!columns.isEmpty(), "must provide at least one column");

    ImmutableMap.Builder<String, Type> builder = ImmutableMap.builder();
    for (ColumnHandle column : columns) {
        JmxColumnHandle jmxColumnHandle = checkType(column, JmxColumnHandle.class, "column");
        builder.put(jmxColumnHandle.getColumnName(), jmxColumnHandle.getColumnType());
    }//from   ww w  .  j ava  2s  .  c  om
    ImmutableMap<String, Type> columnTypes = builder.build();

    List<List<Object>> rows;
    try {
        Map<String, Object> attributes = getAttributes(columnTypes.keySet(), tableHandle);
        List<Object> row = new ArrayList<>();
        // NOTE: data must be produced in the order of the columns parameter.  This code relies on the
        // fact that columnTypes is an ImmutableMap which is an order preserving LinkedHashMap under
        // the covers.
        for (Entry<String, Type> entry : columnTypes.entrySet()) {
            if (entry.getKey().equals("node")) {
                row.add(nodeId);
            } else {
                Object value = attributes.get(entry.getKey());
                if (value == null) {
                    row.add(null);
                } else {
                    Class<?> javaType = entry.getValue().getJavaType();
                    if (javaType == boolean.class) {
                        if (value instanceof Boolean) {
                            row.add(value);
                        } else {
                            // mbeans can lie about types
                            row.add(null);
                        }
                    } else if (javaType == long.class) {
                        if (value instanceof Number) {
                            row.add(((Number) value).longValue());
                        } else {
                            // mbeans can lie about types
                            row.add(null);
                        }
                    } else if (javaType == double.class) {
                        if (value instanceof Number) {
                            row.add(((Number) value).doubleValue());
                        } else {
                            // mbeans can lie about types
                            row.add(null);
                        }
                    } else if (javaType == Slice.class) {
                        if (value.getClass().isArray()) {
                            // return a string representation of the array
                            if (value.getClass().getComponentType() == boolean.class) {
                                row.add(Arrays.toString((boolean[]) value));
                            } else if (value.getClass().getComponentType() == byte.class) {
                                row.add(Arrays.toString((byte[]) value));
                            } else if (value.getClass().getComponentType() == char.class) {
                                row.add(Arrays.toString((char[]) value));
                            } else if (value.getClass().getComponentType() == double.class) {
                                row.add(Arrays.toString((double[]) value));
                            } else if (value.getClass().getComponentType() == float.class) {
                                row.add(Arrays.toString((float[]) value));
                            } else if (value.getClass().getComponentType() == int.class) {
                                row.add(Arrays.toString((int[]) value));
                            } else if (value.getClass().getComponentType() == long.class) {
                                row.add(Arrays.toString((long[]) value));
                            } else if (value.getClass().getComponentType() == short.class) {
                                row.add(Arrays.toString((short[]) value));
                            } else {
                                row.add(Arrays.toString((Object[]) value));
                            }
                        } else {
                            row.add(value.toString());
                        }
                    }
                }
            }
        }
        rows = ImmutableList.of(row);
    } catch (JMException e) {
        rows = ImmutableList.of();
    }

    return new InMemoryRecordSet(columnTypes.values(), rows);
}

From source file:org.locationtech.geogig.porcelain.RemoveOp.java

private Map<String, NodeRef> getDeleteTrees(RevTree workTree) {

    Iterator<NodeRef> childTrees = command(LsTreeOp.class).setStrategy(Strategy.DEPTHFIRST_ONLY_TREES)
            .setReference(workTree.getId().toString()).call();

    ImmutableMap<String, NodeRef> treesByPath = Maps.uniqueIndex(childTrees, (ref) -> ref.path());

    Set<String> requestedTrees = Sets.intersection(treesByPath.keySet(), new HashSet<>(pathsToRemove));
    Predicate<String> keyPredicate = Predicates.in(requestedTrees);
    Map<String, NodeRef> requestedTreesMap = Maps.filterKeys(treesByPath, keyPredicate);
    return requestedTreesMap;
}

From source file:com.ariht.maven.plugins.config.generator.ConfigGeneratorImpl.java

/**
 * Compile list of every property in all filter io - used to provide dummy values
 * in missing properties identified in set difference check.
 *//* ww w  . j  av a  2s .c o m*/
private Set<String> getAllProperties(List<FileInfo> filters) throws ConfigurationException, IOException {
    final Set<String> allProperties = new LinkedHashSet<String>();
    for (final FileInfo filter : filters) {
        final Properties properties = readFilterIntoProperties(filter);
        final ImmutableMap<String, String> valueMap = Maps.fromProperties(properties);
        allProperties.addAll(valueMap.keySet());
    }
    return allProperties;
}

From source file:org.sosy_lab.cpachecker.cpa.sign.SignState.java

public SignState enterFunction(ImmutableMap<String, SIGN> pArguments) {
    PersistentMap<String, SIGN> newMap = signMap;

    for (String var : pArguments.keySet()) {
        if (!pArguments.get(var).equals(SIGN.ALL)) {
            newMap = newMap.putAndCopy(var, pArguments.get(var));
        }//from   w w  w .j a  v a 2  s . co m
    }

    return signMap == newMap ? this : new SignState(newMap);
}

From source file:com.facebook.presto.connector.jmx.JmxDataStreamProvider.java

private RecordSet createRecordSet(Split split, List<ColumnHandle> columns) {
    checkNotNull(split, "split is null");
    checkArgument(split instanceof JmxSplit, "Split must be of type %s, not %s", JmxSplit.class.getName(),
            split.getClass().getName());
    JmxTableHandle tableHandle = ((JmxSplit) split).getTableHandle();

    checkNotNull(columns, "columns is null");
    checkArgument(!columns.isEmpty(), "must provide at least one column");

    ImmutableMap.Builder<String, ColumnType> builder = ImmutableMap.builder();
    for (ColumnHandle column : columns) {
        checkArgument(column instanceof JmxColumnHandle, "column must be of type %s, not %s",
                JmxColumnHandle.class.getName(), column.getClass().getName());
        JmxColumnHandle jmxColumnHandle = (JmxColumnHandle) column;
        builder.put(jmxColumnHandle.getColumnName(), jmxColumnHandle.getColumnType());
    }//  www  . j a  va2 s .c  o  m
    ImmutableMap<String, ColumnType> columnTypes = builder.build();

    List<List<Object>> rows;
    try {
        Map<String, Object> attributes = getAttributes(columnTypes.keySet(), tableHandle);
        List<Object> row = new ArrayList<>();
        // NOTE: data must be produced in the order of the columns parameter.  This code relies on the
        // fact that columnTypes is an ImmutableMap which is an order preserving LinkedHashMap under
        // the covers.
        for (Entry<String, ColumnType> entry : columnTypes.entrySet()) {
            if (entry.getKey().equals("node")) {
                row.add(nodeId);
            } else {
                Object value = attributes.get(entry.getKey());
                if (value == null) {
                    row.add(null);
                } else {
                    switch (entry.getValue()) {
                    case BOOLEAN:
                        if (value instanceof Boolean) {
                            row.add(value);
                        } else {
                            // mbeans can lie about types
                            row.add(null);
                        }
                        break;
                    case LONG:
                        if (value instanceof Number) {
                            row.add(((Number) value).longValue());
                        } else {
                            // mbeans can lie about types
                            row.add(null);
                        }
                        break;
                    case DOUBLE:
                        if (value instanceof Number) {
                            row.add(((Number) value).doubleValue());
                        } else {
                            // mbeans can lie about types
                            row.add(null);
                        }
                        break;
                    case STRING:
                        row.add(value.toString());
                        break;
                    }
                }
            }
        }
        rows = ImmutableList.of(row);
    } catch (JMException e) {
        rows = ImmutableList.of();
    }

    return new InMemoryRecordSet(columnTypes.values(), rows);
}