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:org.apache.shindig.gadgets.GadgetFeature.java

/**
 * Simplified ctor that registers a set of libraries for all contexts and
 * the default container. Used for testing.
 *///from  ww  w  .  j  a  v a 2  s . c  o  m
public GadgetFeature(String name, List<JsLibrary> libraries, Collection<String> dependencies) {
    this.name = name;
    this.libraries = Maps.newEnumMap(RenderingContext.class);
    for (RenderingContext context : RenderingContext.values()) {
        Map<String, List<JsLibrary>> container = Maps.newHashMap();
        container.put(ContainerConfig.DEFAULT_CONTAINER, libraries);
        this.libraries.put(context, container);
    }
    this.dependencies = dependencies;
}

From source file:fr.javatronic.damapping.toolkit.enums.StringEnumMapperMaps.java

@Nonnull
private ImmutableMap<E, String> exceptEnumMap(E enumValue, @Nullable String str) {
    EnumMap<E, String> enumMap = Maps.newEnumMap(this.enumToString);
    if (str == null) {
        enumMap.remove(enumValue);/*w w w . j a  va  2 s  . co  m*/
    } else {
        enumMap.put(enumValue, str);
    }
    return Maps.immutableEnumMap(enumMap);
}

From source file:com.notifier.desktop.ApplicationPreferences.java

public ApplicationPreferences() {
    allowedDevicesIds = Sets.newTreeSet();
    allowedDevicesNames = Lists.newArrayList();
    notificationsSettings = Maps.newHashMap();
    groupsExpansion = Maps.newEnumMap(Group.class);
}

From source file:org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter.ShardedDOMDataBrokerDelegatingReadWriteTransaction.java

public ShardedDOMDataBrokerDelegatingReadWriteTransaction(final Object readWriteTxId, final SchemaContext ctx,
        final DOMDataReadOnlyTransaction readTxDelegate, final DOMDataWriteTransaction writeTxDelegate) {
    this.readTxDelegate = checkNotNull(readTxDelegate);
    this.writeTxDelegate = checkNotNull(writeTxDelegate);
    this.txIdentifier = checkNotNull(readWriteTxId);
    this.initialReadMap = Maps.newEnumMap(LogicalDatastoreType.class);

    final InMemoryDataTreeFactory treeFactory = InMemoryDataTreeFactory.getInstance();
    final ImmutableMap.Builder<LogicalDatastoreType, DataTreeSnapshot> snapshotMapBuilder = ImmutableMap
            .builder();//w w w  .  j  a  v  a  2s.  c o  m
    final ImmutableMap.Builder<LogicalDatastoreType, Queue<Modification>> modificationHistoryMapBuilder = ImmutableMap
            .builder();
    for (final LogicalDatastoreType store : LogicalDatastoreType.values()) {
        final DataTree tree = treeFactory.create(treeTypeForStore(store));
        tree.setSchemaContext(ctx);
        snapshotMapBuilder.put(store, tree.takeSnapshot());

        modificationHistoryMapBuilder.put(store, Lists.newLinkedList());
    }

    modificationHistoryMap = modificationHistoryMapBuilder.build();
    snapshotMap = snapshotMapBuilder.build();
}

From source file:gg.uhc.uhc.modules.heads.HeadDropsModule.java

@EventHandler(priority = EventPriority.LOW)
public void on(PlayerDeathEvent event) {
    if (!isEnabled() || random.nextDouble() < (1D - dropRate)) {
        // set to an empty map to avoid stale metadata problems
        event.getEntity().setMetadata(StandItemsMetadata.KEY, new StandItemsMetadata(plugin));
        return;/*w  w  w .j  av  a 2 s  .c  o m*/
    }

    Player player = event.getEntity();

    // create a head
    ItemStack head = playerHeadProvider.getPlayerHeadItem(player);

    // add it to the drops
    event.getDrops().add(head);

    // add metadata for the armour stand module to put the helmet on the player and remove from drops
    EnumMap<EquipmentSlot, ItemStack> standItems = Maps.newEnumMap(EquipmentSlot.class);
    standItems.put(EquipmentSlot.HEAD, head);

    player.setMetadata(StandItemsMetadata.KEY, new StandItemsMetadata(plugin, standItems));
}

From source file:gg.uhc.uhc.modules.death.DeathStandsModule.java

protected EnumMap<EquipmentSlot, ItemStack> getSavedSlots(Player player) {
    for (MetadataValue value : player.getMetadata(StandItemsMetadata.KEY)) {
        if (!(value instanceof StandItemsMetadata))
            continue;

        // remove the metadata
        player.removeMetadata(StandItemsMetadata.KEY, value.getOwningPlugin());

        // return the map
        return ((StandItemsMetadata) value).value();
    }//from w w  w. j a va  2 s.c  o m

    return Maps.newEnumMap(EquipmentSlot.class);
}

From source file:com.torodb.torod.db.backends.mysql.converters.array.MySQLValueToArrayConverterProvider.java

private MySQLValueToArrayConverterProvider() {
    arrayConverter = new ArrayToArrayConverter(this);
    booleanConverter = new BooleanToArrayConverter();
    dateConverter = new DateToArrayConverter();
    dateTimeConverter = new InstantToArrayConverter();
    doubleConverter = new DoubleToArrayConverter();
    integerConverter = new IntegerToArrayConverter();
    longConverter = new LongToArrayConverter();
    nullConverter = new NullToArrayConverter();
    stringConverter = new StringToArrayConverter();
    timeConverter = new TimeToArrayConverter();
    mongoObjectIdConverter = new MongoObjectIdToArrayConverter();
    mongoTimestampConverter = new MongoTimestampToArrayConverter();
    binaryConverter = new BinaryToArrayConverter();

    converters = Maps.newEnumMap(ScalarType.class);
    converters.put(ScalarType.ARRAY, arrayConverter);
    converters.put(ScalarType.BOOLEAN, booleanConverter);
    converters.put(ScalarType.DATE, dateConverter);
    converters.put(ScalarType.INSTANT, dateTimeConverter);
    converters.put(ScalarType.DOUBLE, doubleConverter);
    converters.put(ScalarType.INTEGER, integerConverter);
    converters.put(ScalarType.LONG, longConverter);
    converters.put(ScalarType.NULL, nullConverter);
    converters.put(ScalarType.STRING, stringConverter);
    converters.put(ScalarType.TIME, timeConverter);
    converters.put(ScalarType.MONGO_OBJECT_ID, mongoObjectIdConverter);
    converters.put(ScalarType.MONGO_TIMESTAMP, mongoTimestampConverter);
    converters.put(ScalarType.BINARY, binaryConverter);

}

From source file:com.ardor3d.input.MouseState.java

/**
 * Returns all the buttons' states. It could be easier for most classes to use the
 * {@link #getButtonState(MouseButton)} methods, and that also results in less object creation.
 * /*  w w  w. j a  v a2s . c o m*/
 * @param store
 *            a map to store the states in... any values in store are cleared first. If store is null, a new map is
 *            created.
 * @return a defensive copy of the states of all the buttons at this point in time.
 */
public EnumMap<MouseButton, ButtonState> getButtonStates(final EnumMap<MouseButton, ButtonState> store) {
    EnumMap<MouseButton, ButtonState> rVal = store;
    if (store == null) {
        rVal = Maps.newEnumMap(MouseButton.class);
    }
    rVal.clear();
    rVal.putAll(_buttonStates);
    return rVal;
}

From source file:org.moe.designer.rendering.MultiResourceRepository.java

@NonNull
@Override//from  ww  w  . j  a v  a  2  s  .  co m
protected Map<ResourceType, ListMultimap<String, ResourceItem>> getMap() {
    //    myItems = null;
    if (myItems == null) {
        if (myChildren.size() == 1) {
            myItems = myChildren.get(0).getItems();
        } else {
            Map<ResourceType, ListMultimap<String, ResourceItem>> map = Maps.newEnumMap(ResourceType.class);
            for (ResourceType type : ResourceType.values()) {
                map.put(type, getMap(type, false)); // should pass create is true, but as described below we interpret this differently
            }
            myItems = map;
        }
    }

    return myItems;
}

From source file:com.android.tools.lint.checks.DuplicateResourceDetector.java

@Override
public void beforeCheckFile(@NonNull Context context) {
    File parent = context.file.getParentFile();
    if (!parent.equals(mParent)) {
        mParent = parent;/*from  w  w  w  .j  av  a 2s .c o  m*/
        mTypeMap = Maps.newEnumMap(ResourceType.class);
        mLocations = Maps.newEnumMap(ResourceType.class);
    }
}