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.terasology.world.block.family.AttachedToSurfaceFamilyFactory.java

@Override
public BlockFamily createBlockFamily(BlockBuilderHelper blockBuilder, AssetUri blockDefUri,
        BlockDefinition blockDefinition, JsonObject blockDefJson) {
    Map<Side, Block> blockMap = Maps.newEnumMap(Side.class);
    BlockDefinition topDef = blockBuilder.getBlockDefinitionForSection(blockDefJson, TOP);
    if (topDef != null) {
        Block block = blockBuilder.constructSimpleBlock(blockDefUri, topDef);
        block.setDirection(Side.TOP);/*from   w  ww.  j a v  a 2  s  .  c  o m*/
        blockMap.put(Side.TOP, block);
    }
    BlockDefinition sideDef = blockBuilder.getBlockDefinitionForSection(blockDefJson, SIDES);
    if (sideDef != null) {
        blockMap.putAll(blockBuilder.constructHorizontalRotatedBlocks(blockDefUri, sideDef));
    }
    BlockDefinition bottomDef = blockBuilder.getBlockDefinitionForSection(blockDefJson, BOTTOM);
    if (bottomDef != null) {
        Block block = blockBuilder.constructSimpleBlock(blockDefUri, bottomDef);
        block.setDirection(Side.BOTTOM);
        blockMap.put(Side.BOTTOM, block);
    }
    return new AttachedToSurfaceFamily(new BlockUri(blockDefUri.getModuleName(), blockDefUri.getAssetName()),
            blockMap, blockDefinition.categories);
}

From source file:org.gradle.model.internal.manage.schema.extract.ModelPropertyExtractionContext.java

public ModelPropertyExtractionContext(String propertyName) {
    this.propertyName = propertyName;
    this.accessors = Maps.newEnumMap(PropertyAccessorType.class);
}

From source file:org.jgrades.admin.accounts.AbstractUserDetailsRepositories.java

@PostConstruct
protected void fillMap() {
    repos = Maps.newEnumMap(JgRole.class);
    repos.put(JgRole.ADMINISTRATOR, administratorRepository);
    repos.put(JgRole.MANAGER, managerRepository);
    repos.put(JgRole.TEACHER, teacherRepository);
    repos.put(JgRole.STUDENT, studentRepository);
    repos.put(JgRole.PARENT, parentRepository);
}

From source file:com.griddynamics.jagger.agent.model.AgentContext.java

public AgentContext() {
    this(Maps.newEnumMap(AgentContextProperty.class));
}

From source file:com.android.build.gradle.internal.variant.ApplicationVariantData.java

public ApplicationVariantData(@NonNull AndroidConfig androidConfig, @NonNull GradleVariantConfiguration config,
        @NonNull TaskManager taskManager) {
    super(androidConfig, taskManager, config);
    testVariants = Maps.newEnumMap(VariantType.class);
}

From source file:javastory.channel.client.MonsterStatusEffect.java

public MonsterStatusEffect(final Map<MonsterStatus, Integer> effects, final ISkill skillId,
        final MobSkill mobskill, final boolean monsterSkill) {
    this.effects = Maps.newEnumMap(effects);
    this.skill = skillId;
    this.monsterSkill = monsterSkill;
    this.mobskill = mobskill;
}

From source file:org.gradle.nativeplatform.fixtures.NativeToolChainTestRunner.java

@Override
protected Collection<AvailableToolChains.ToolChainCandidate> getPartialVersions() {
    List<AvailableToolChains.ToolChainCandidate> toolChains = AvailableToolChains.getToolChains();
    Map<AvailableToolChains.ToolFamily, AvailableToolChains.ToolChainCandidate> availableByFamily = Maps
            .newEnumMap(AvailableToolChains.ToolFamily.class);
    for (AvailableToolChains.ToolChainCandidate toolChain : toolChains) {
        if (canUseToolChain(toolChain)) {
            AvailableToolChains.ToolChainCandidate current = availableByFamily.get(toolChain.getFamily());
            if (current == null || current.getVersion().compareTo(toolChain.getVersion()) < 0) {
                availableByFamily.put(toolChain.getFamily(), toolChain);
            }/*from  w w w.ja v a 2 s  .c  om*/
        }
    }

    return availableByFamily.values();
}

From source file:org.terasology.machines.world.SurfacePlacementFamilyFactory.java

@Override
public BlockFamily createBlockFamily(BlockBuilderHelper blockBuilder, AssetUri blockDefUri,
        BlockDefinition blockDefinition, JsonObject blockDefJson) {
    Map<Side, Block> blockMap = Maps.newEnumMap(Side.class);
    BlockDefinition topDef = blockBuilder.getBlockDefinitionForSection(blockDefJson, TOP);
    if (topDef != null) {
        Block block = blockBuilder.constructSimpleBlock(blockDefUri, topDef);
        block.setDirection(Side.TOP);/*ww  w .  java 2s . c o  m*/
        blockMap.put(Side.TOP, block);
    }
    BlockDefinition sideDef = blockBuilder.getBlockDefinitionForSection(blockDefJson, SIDES);
    if (sideDef != null) {
        blockMap.put(Side.FRONT,
                blockBuilder.constructTransformedBlock(blockDefUri, sideDef, Rotation.rotate(Yaw.NONE)));
        blockMap.put(Side.LEFT, blockBuilder.constructTransformedBlock(blockDefUri, sideDef,
                Rotation.rotate(Yaw.CLOCKWISE_90)));
        blockMap.put(Side.BACK, blockBuilder.constructTransformedBlock(blockDefUri, sideDef,
                Rotation.rotate(Yaw.CLOCKWISE_180)));
        blockMap.put(Side.RIGHT, blockBuilder.constructTransformedBlock(blockDefUri, sideDef,
                Rotation.rotate(Yaw.CLOCKWISE_270)));
    }
    BlockDefinition bottomDef = blockBuilder.getBlockDefinitionForSection(blockDefJson, BOTTOM);
    if (bottomDef != null) {
        Block block = blockBuilder.constructSimpleBlock(blockDefUri, bottomDef);
        block.setDirection(Side.BOTTOM);
        blockMap.put(Side.BOTTOM, block);
    }
    return new SurfacePlacementFamily(new BlockUri(blockDefUri.getModuleName(), blockDefUri.getAssetName()),
            blockMap, blockDefinition.categories);
}

From source file:se.toxbee.sleepfighter.challenge.factory.ChallengeFactory.java

public static ChallengePrototypeDefinition getPrototypeDefinition(ChallengeType type) {
    if (prototypeDefinitions == null) {
        prototypeDefinitions = Maps.newEnumMap(ChallengeType.class);
    }//from ww  w  . j av a2s  .  c om

    ChallengePrototypeDefinition def = prototypeDefinitions.get(type);

    if (def == null) {
        switch (type) {

        case MATH:
            def = new MathChallenge.PrototypeDefinition();
            break;

        case MEMORY:
            def = new MemoryChallenge.PrototypeDefinition();
            break;

        case SORT:
            def = new SortChallenge.PrototypeDefinition();
            break;

        case FLUID_SNAKE:
            def = new FluidSnakeChallenge.PrototypeDefinition();
            break;
        case ROTO_SNAKE:
            def = new RotoSnakeChallenge.PrototypeDefinition();
            break;
        case SHAKE:
            def = new ShakeChallenge.PrototypeDefinition();
            break;
        default:
            throw new IllegalArgumentException("Undefined challenge");
        }

        prototypeDefinitions.put(type, def);
    }

    return def;
}

From source file:com.voxelplugineering.voxelsniper.service.eventbus.SubscriberList.java

/**
 * Creates a new {@link SubscriberList}.
 * //from w ww. j a v  a  2s .  c  o  m
 * @param parent The parent list
 */
public SubscriberList(SubscriberList parent) {
    this.subs = Maps.newEnumMap(EventPriority.class);
    this.parent = parent;
}