Example usage for java.util EnumMap EnumMap

List of usage examples for java.util EnumMap EnumMap

Introduction

In this page you can find the example usage for java.util EnumMap EnumMap.

Prototype

public EnumMap(Map<K, ? extends V> m) 

Source Link

Document

Creates an enum map initialized from the specified map.

Usage

From source file:com.relicum.ipsum.Menus.BungeeBar.java

/**
 * Instantiates a new Bungee bar.//  w  ww.j a v  a  2s  .c  o m
 *
 * @param size  the size
 * @param title the title
 */
public BungeeBar(int size, String title) {
    super(title, size);

    this.items = new EnumMap<>(Slot.class);
}

From source file:eu.itesla_project.modules.simulation.ImpactAnalysisTool.java

private static List<String> toRow(Collection<SecurityIndex> securityIndexes) {
    List<String> l = new ArrayList<>();
    Map<SecurityIndexType, Boolean> ok = new EnumMap<>(SecurityIndexType.class);
    for (SecurityIndex securityIndex : securityIndexes) {
        ok.put(securityIndex.getId().getSecurityIndexType(), securityIndex.isOk());
    }/*w w  w .  j a v a  2 s.c o  m*/

    for (SecurityIndexType securityIndexType : SecurityIndexType.values()) {
        Boolean b = ok.get(securityIndexType);
        l.add(okToStr(b));
    }

    return l;
}

From source file:org.springframework.social.twitter.api.impl.RateLimitStatusDeserializer.java

@Override
public RateLimitStatusHolder deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    JsonNode node = jp.readValueAs(JsonNode.class);
    if (null == node || node.isMissingNode() || node.isNull()) {
        return null;
    }/*from   w w  w . j a  v  a2s  .c om*/
    JsonNode resources = node.get("resources");
    Map<ResourceFamily, List<RateLimitStatus>> rateLimits = new EnumMap<ResourceFamily, List<RateLimitStatus>>(
            ResourceFamily.class);
    for (Iterator<Entry<String, JsonNode>> resourceFamilyIt = resources.fields(); resourceFamilyIt.hasNext();) {
        Entry<String, JsonNode> resourceFamilyNode = resourceFamilyIt.next();
        List<RateLimitStatus> rateLimitsList = new LinkedList<RateLimitStatus>();
        for (Iterator<Entry<String, JsonNode>> resourceEndpointIt = resourceFamilyNode.getValue()
                .fields(); resourceEndpointIt.hasNext();) {
            Entry<String, JsonNode> endpointNode = resourceEndpointIt.next();
            RateLimitStatus endpointLimit = new RateLimitStatus(endpointNode.getKey(),
                    endpointNode.getValue().get("limit").asInt(),
                    endpointNode.getValue().get("remaining").asInt(),
                    endpointNode.getValue().get("reset").asInt());
            rateLimitsList.add(endpointLimit);
        }
        rateLimits.put(ResourceFamily.getResourceFamily(resourceFamilyNode.getKey()), rateLimitsList);
    }
    return new RateLimitStatusHolder(rateLimits);
}

From source file:com.relicum.ipsum.Menus.SimpleMenu.java

/**
 * Instantiates a new Simple menu.//from   w w  w  .  j  a v a  2s . c  o  m
 *
 * @param menuTitle the menu title
 * @param size the size
 */
public SimpleMenu(String menuTitle, int size) {
    super(menuTitle, size);
    this.items = new EnumMap<>(Slot.class);

}

From source file:com.att.aro.ui.view.diagnostictab.plot.RrcPlot.java

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    if (analysis != null) {
        rrcDataCollection.removeAllSeries();
        Map<RRCState, XYIntervalSeries> seriesMap = new EnumMap<RRCState, XYIntervalSeries>(RRCState.class);
        for (RRCState eventType : RRCState.values()) {
            XYIntervalSeries series = new XYIntervalSeries(eventType);
            seriesMap.put(eventType, series);
            rrcDataCollection.addSeries(series);
        }/* w ww. j  a  v a  2  s.  c  o  m*/
        List<RrcStateRange> rrcStates = analysis.getAnalyzerResult().getStatemachine().getStaterangelist();

        Iterator<RrcStateRange> iter = rrcStates.iterator();
        while (iter.hasNext()) {
            RrcStateRange currEvent = iter.next();
            RRCState state = currEvent.getState();
            if (state == RRCState.STATE_FACH || state == RRCState.TAIL_FACH) {
                seriesMap.get(state).add(currEvent.getBeginTime(), currEvent.getBeginTime(),
                        currEvent.getEndTime(), 0.25, 0, 0.5);
            } else {
                seriesMap.get(state).add(currEvent.getBeginTime(), currEvent.getBeginTime(),
                        currEvent.getEndTime(), 0.5, 0, 1);
            }

        }
        XYItemRenderer renderer = plot.getRenderer();
        Color dchGreen = new Color(34, 177, 76);
        Color fachOrange = new Color(255, 201, 14);

        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.STATE_IDLE), Color.white);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_IDLE), Color.white);

        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.PROMO_IDLE_DCH), Color.red);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_PROMOTION), Color.red);

        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.STATE_DCH), fachOrange);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_CONTINUOUS), fachOrange);

        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.TAIL_DCH), getTailPaint(fachOrange));
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_CR_TAIL), getTailPaint(fachOrange));
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_DRX_SHORT), getTailPaint(fachOrange));
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.LTE_DRX_LONG), getTailPaint(fachOrange));

        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.STATE_FACH), dchGreen);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.TAIL_FACH), getTailPaint(dchGreen));

        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.PROMO_FACH_DCH), Color.red);

        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.WIFI_IDLE), Color.white);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.WIFI_ACTIVE), fachOrange);
        renderer.setSeriesPaint(rrcDataCollection.indexOf(RRCState.WIFI_TAIL), getTailPaint(fachOrange));

        // Assign ToolTip to renderer

        final Profile profile = analysis.getAnalyzerResult().getProfile();
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                RRCState eventType = (RRCState) rrcDataCollection.getSeries(series).getKey();
                final String PREFIX = "RRCTooltip.";
                if (eventType == RRCState.LTE_IDLE && profile instanceof ProfileLTE) {
                    return MessageFormat.format(ResourceBundleHelper.getMessageString(PREFIX + eventType),
                            ((ProfileLTE) profile).getIdlePingPeriod());
                }
                return ResourceBundleHelper.getMessageString(PREFIX + eventType);
            }
        });

    }

    plot.setDataset(rrcDataCollection);
    //      return plot;
}

From source file:com.relicum.ipsum.Menus.BungeeBar.java

/**
 * Instantiates a new Bungee bar.//  w  w  w . j a va 2s.  c  om
 */
public BungeeBar() {
    super();

    this.items = new EnumMap<>(Slot.class);
}

From source file:io.lavagna.model.UserWithPermission.java

private static Map<Permission, Permission> identityMap(Set<Permission> permissions) {
    Map<Permission, Permission> res = new EnumMap<>(Permission.class);
    for (Permission p : permissions) {
        res.put(p, p);//from   w  w  w . j av a2  s . co m
    }
    return res;
}

From source file:de.unentscheidbar.validation.builtin.FilePropertiesValidator.java

private static Map<Type, FilePropertiesValidator> instances() {

    EnumMap<Type, FilePropertiesValidator> map = new EnumMap<>(Type.class);
    for (Type type : Type.values()) {
        map.put(type, new FilePropertiesValidator(type));
    }/* ww  w  .j a v  a2  s  .  com*/
    return map;
}

From source file:com.vmware.identity.authz.RoleAdminBuilder.java

/**
 * Create {@link RoleAdmin} builder//  w w  w.j a v a2  s  .  c o  m
 *
 * @param pm
 *           principal management with read/write access to role groups;
 *           {@code not-null} value is required
 * @param role
 *           at least one role is required to initialize {@link RoleAdmin}
 *           with; {@code not-null} value is required
 * @param group
 *           group name containing users with given role; {@code not-null}
 *           and not-empty string value is required
 * @param details
 *           group details used to create a group with given name if such
 *           does not exist; {@code not-null} value is required
 */
@SuppressWarnings("unchecked")
public RoleAdminBuilder(PrincipalManagement pm, R role, String group, GroupDetails details) {

    Validate.notNull(pm);
    _pm = pm;

    _roleGroups = new EnumMap<R, SystemGroup>((Class<R>) role.getClass());
    addRoleGroup(role, group, details);
}

From source file:com.l2jserver.util.calculator.ComplexCalculator.java

/**
 * Creates a new empty calculator. Functions can be add using
 * {@link #add(Function)} or {@link #add(Function...)}
 * /*from   www. j av  a 2s.  c  om*/
 * @param type
 *            the {@link Class} for attribute set
 */
public ComplexCalculator(Class<V> type) {
    super(0x00, null);
    functions = new EnumMap<V, Function<T, V>[]>(type);
}