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

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

Introduction

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

Prototype

public static <K extends Enum<K>, V> EnumMap<K, V> newEnumMap(Map<K, ? extends V> map) 

Source Link

Document

Creates an EnumMap with the same mappings as the specified map.

Usage

From source file:com.google.api.tools.framework.model.BoundedDiagCollector.java

public BoundedDiagCollector(Map<Kind, Integer> capacityByKind) {
    this.capacityByKind = Maps.newEnumMap(capacityByKind);
}

From source file:org.terasology.tutorial.assetsystem.block.family.RotateableBlockFamilyFactory.java

@Override
public BlockFamily createBlockFamily(BlockFamilyDefinition definition, BlockBuilderHelper blockBuilder) {
    Map<Side, Map<Side, Block>> blockMap = Maps.newEnumMap(Side.class);
    //the default definition will be the top side and the front facing
    for (Side topSide : BLOCK_ROTATIONS.keySet()) {
        Map<Side, Rotation> frontSides = BLOCK_ROTATIONS.get(topSide);
        Map<Side, Block> frontBlocks = Maps.newEnumMap(Side.class);
        for (Side frontSide : frontSides.keySet()) {
            Rotation rotation = frontSides.get(frontSide);
            frontBlocks.put(frontSide, blockBuilder.constructTransformedBlock(definition, rotation));
        }/*from w ww .j  a v  a2s .c om*/
        blockMap.put(topSide, frontBlocks);
    }
    return new RotatableBlockFamily(new BlockUri(definition.getUrn()), blockMap, definition.getCategories());
}

From source file:de.gtrefs.ai.ludo.model.Board.java

public Board() {
    playersByColor = Maps.newEnumMap(Game.Color.class);
    buildBoard();
}

From source file:dmh.swing.enumselect.MasterEnumSelectAction.java

/**
 * Construct a new master enum selection action.
 * @param enumClass The enum class defining all possible selections.
 * @param enumSelectable Handler for enum selection events.
 *///ww w.  j  av  a  2 s . c o  m
public MasterEnumSelectAction(Class<T> enumClass, EnumSelectable<T> enumSelectable) {
    this.enumClass = enumClass;
    this.enumSelectable = enumSelectable;

    actions = Maps.newEnumMap(enumClass);
    for (T enumValue : enumClass.getEnumConstants()) {
        EnumSelectAction<T> action = newEnumSelectAction(enumValue);
        actions.put(enumValue, action);
        addObserver(action);
    }

    addPropertyChangeListener(new PropertyChangeListener() {
        @SuppressWarnings("unchecked")
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (SELECTED_VALUE_KEY.equals(evt.getPropertyName())) {
                enumChangeObservable.setCurrentValueAndNotifyObservers((T) evt.getNewValue());
            }
        }
    });

    putValue(SELECTED_VALUE_KEY, null);
}

From source file:org.eclipse.milo.opcua.sdk.client.nodes.DefaultNodeCache.java

@Override
public void putAttribute(NodeId nodeId, AttributeId attributeId, DataValue attribute) {
    try {// w  ww. j  a  v a 2s . c om
        Map<AttributeId, DataValue> attributes = cache.get(nodeId,
                () -> Collections.synchronizedMap(Maps.newEnumMap(AttributeId.class)));

        attributes.put(attributeId, attribute);
    } catch (ExecutionException e) {
        logger.error("Error loading value: {}", e.getMessage(), e);
    }
}

From source file:org.auraframework.docs.DefDependenciesModel.java

public DefDependenciesModel() throws QuickFixException {
    AuraContext context = Aura.getContextService().getCurrentContext();
    BaseComponent<?, ?> component = context.getCurrentComponent();

    String desc = (String) component.getAttributes().getValue("descriptor");

    DefType defType = DefType.valueOf(((String) component.getAttributes().getValue("defType")).toUpperCase());
    DefDescriptor<?> descriptor = Aura.getDefinitionService().getDefDescriptor(desc,
            defType.getPrimaryInterface());

    Definition def = descriptor.getDef();
    ReferenceTreeModel.assertAccess(def);

    Map<DefType, List<DefModel>> depsMap = Maps.newEnumMap(DefType.class);

    Set<DefDescriptor<?>> deps = Sets.newHashSet();

    def.appendDependencies(deps);/*from   ww  w . j  a v a  2s .c o  m*/

    for (DefDescriptor<?> dep : deps) {
        if (ReferenceTreeModel.hasAccess(dep.getDef())) {
            DefType type = dep.getDefType();

            List<DefModel> depsList = depsMap.get(type);
            if (depsList == null) {
                depsList = Lists.newArrayList();
                depsMap.put(type, depsList);
            }

            depsList.add(new DefModel(dep));
        }
    }

    for (Entry<DefType, List<DefModel>> entry : depsMap.entrySet()) {
        List<DefModel> list = entry.getValue();
        Collections.sort(list);

        Map<String, Object> group = Maps.newHashMap();
        group.put("type", AuraTextUtil.initCap(entry.getKey().toString().toLowerCase()));
        group.put("list", list);
        dependencies.add(group);
    }
}

From source file:de.matzefratze123.heavyspleef.core.FlagManager.java

public FlagManager(JavaPlugin plugin, GamePropertyBundle defaults) {
    this.plugin = plugin;
    this.defaults = defaults;
    this.flags = Maps.newLinkedHashMap();
    this.propertyBundles = Sets.newTreeSet();
    this.requestedProperties = new DefaultGamePropertyBundle(Maps.newEnumMap(GameProperty.class));
}

From source file:io.techcode.logbulk.pipeline.output.SyslogOutput.java

@Override
public void onStart() {
    // Setup mapping
    JsonObject map = config.getJsonObject(CONF_MAPPING, new JsonObject());
    mapping = Maps.newEnumMap(SyslogHeader.class);
    for (String entry : map.fieldNames()) {
        mapping.put(SyslogHeader.byName(entry), map.getString(entry));
    }//from   w  w w. j  a  v a2 s  .  c om

    // Setup framing
    String framing = config.getString(CONF_FRAMING);
    if ("delimited".equals(framing)) {
        delimiter = config.getString(CONF_DELIMITER);
    }
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticExcel.export.template.ExcelStylesCreator.java

/**
 * Generates the Excel styles. It is ensured, that all styles names defined in 
 * {@link IteraExcelStyle} enum class will be contained in returned map.
 * //from  w  ww  .  j  a v  a 2  s  .  c o  m
 * @param wb the workbook to create the styles for
 * @return the map containing the Excel styles
 */
public static Map<IteraExcelStyle, CellStyle> createStyles(Workbook wb) {
    Map<IteraExcelStyle, CellStyle> styles = Maps.newEnumMap(IteraExcelStyle.class);

    CellStyle headerStyle = getHeaderStyle(wb);
    styles.put(IteraExcelStyle.HEADER, headerStyle);

    CellStyle dataStyle = getDataStyle(wb);
    styles.put(IteraExcelStyle.DATA, dataStyle);

    CellStyle dataHiddenStyle = getDataHiddenStyle(wb, dataStyle);
    styles.put(IteraExcelStyle.DATA_HIDDEN, dataHiddenStyle);

    CellStyle dateStyle = getDateStyle(wb, dataStyle);
    styles.put(IteraExcelStyle.DATA_DATE, dateStyle);

    CellStyle hyperlinkStyle = getHyperlinkStyle(wb);
    styles.put(IteraExcelStyle.HYPERLINK, hyperlinkStyle);

    return styles;
}

From source file:org.auraframework.docs.DefOverviewModel.java

public DefOverviewModel() throws QuickFixException {

    AuraContext context = Aura.getContextService().getCurrentContext();
    BaseComponent<?, ?> component = context.getCurrentComponent();

    String desc = (String) component.getAttributes().getValue("descriptor");

    DefType defType = DefType.valueOf(((String) component.getAttributes().getValue("defType")).toUpperCase());
    DefinitionService definitionService = Aura.getDefinitionService();
    DefDescriptor<?> descriptor = definitionService.getDefDescriptor(desc, defType.getPrimaryInterface());

    Definition def = descriptor.getDef();
    ReferenceTreeModel.assertAccess(def);

    Map<DefType, List<DefModel>> depsMap = Maps.newEnumMap(DefType.class);

    Set<DefDescriptor<?>> deps = Sets.newHashSet();

    def.appendDependencies(deps);//from w  w  w  .j  av a  2  s  .  com

    for (DefDescriptor<?> dep : deps) {
        DefType type = dep.getDefType();

        List<DefModel> depsList = depsMap.get(type);
        if (depsList == null) {
            depsList = Lists.newArrayList();
            depsMap.put(type, depsList);
        }
        depsList.add(new DefModel(dep));

    }

    for (Entry<DefType, List<DefModel>> entry : depsMap.entrySet()) {
        List<DefModel> list = entry.getValue();
        Collections.sort(list);

        Map<String, Object> group = Maps.newHashMap();
        group.put("type", AuraTextUtil.initCap(entry.getKey().toString().toLowerCase()));
        group.put("list", list);
        dependencies.add(group);
    }
}