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.mgmtp.jfunk.web.JFunkWebDriverEventListener.java

@Inject
public JFunkWebDriverEventListener(final Configuration config,
        @ModuleArchiveDir final Provider<File> moduleArchiveDirProvider,
        final Provider<DumpFileCreator> dumpFileCreatorProvider) {
    this.config = config;
    this.moduleArchiveDirProvider = moduleArchiveDirProvider;
    this.dumpFileCreatorProvider = dumpFileCreatorProvider;
    this.saveOutputMap = new EnumMap<>(SaveOutput.class);
    for (SaveOutput saveOutput : SaveOutput.values()) {
        // active flag for every output type
        saveOutputMap.put(saveOutput, config.getBoolean(
                JFunkConstants.ARCHIVE_INCLUDE + saveOutput.getIdentifier(), saveOutput.isActiveByDefault()));
    }// w w  w  .j a v a 2 s.co m
}

From source file:edu.cornell.mannlib.vivo.orcid.OrcidContextSetup.java

private void initializeOrcidClientContext(ConfigurationProperties props, StartupStatus ss) {
    try {//from  w w w  . ja va2s .  c  o  m
        Map<Setting, String> settings = new EnumMap<>(Setting.class);
        settings.put(CLIENT_ID, props.getProperty("orcid.clientId"));
        settings.put(CLIENT_SECRET, props.getProperty("orcid.clientPassword"));
        settings.put(PUBLIC_API_BASE_URL, props.getProperty("orcid.publicApiBaseUrl"));
        settings.put(AUTHORIZED_API_BASE_URL, props.getProperty("orcid.authorizedApiBaseUrl"));
        settings.put(OAUTH_AUTHORIZE_URL, props.getProperty("orcid.oauthAuthorizeUrl"));
        settings.put(OAUTH_TOKEN_URL, props.getProperty("orcid.oauthTokenUrl"));
        settings.put(MESSAGE_VERSION, props.getProperty("orcid.messageVersion"));
        settings.put(WEBAPP_BASE_URL, props.getProperty("orcid.webappBaseUrl"));
        settings.put(CALLBACK_PATH, "orcid/callback");

        OrcidClientContext.initialize(settings);
        ss.info(this, "Context is: " + OrcidClientContext.getInstance());

    } catch (OrcidClientException e) {
        ss.warning(this, "Failed to initialize OrcidClientContent", e);
    }
}

From source file:io.lavagna.web.security.SecurityFilterTest.java

@Test
public void test() throws IOException, ServletException {

    SecurityFilter sf = new SecurityFilter();

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");

    Map<Key, String> conf = new EnumMap<>(Key.class);
    conf.put(Key.SETUP_COMPLETE, "true");
    when(configurationRepository.findConfigurationFor(Mockito.<Set<Key>>any())).thenReturn(conf);

    MockHttpServletResponse response = new MockHttpServletResponse();
    MockFilterChain chain = new MockFilterChain();

    sf.init(filterConfig);/*  w ww.  j av  a 2  s . co  m*/

    sf.doFilter(request, response, chain);
}

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

/**
 * Creates a new calculator with <tt>functions</tt> in the declaration
 * order./*from   w w w.  ja va  2s . co m*/
 * 
 * @param value
 *            the attribute type
 * @param functions
 *            the calculator functions
 */
@SafeVarargs
public ComplexCalculator(V value, Function<T, V>... functions) {
    super(0x00, value);
    this.functions = new EnumMap<V, Function<T, V>[]>(value.getDeclaringClass());
    add(functions);
}

From source file:fr.free.movierenamer.scrapper.impl.FanartTvScrapper.java

@Override
protected final List<ImageInfo> fetchImagesInfo(M media) throws Exception {

    switch (media.getMediaId().getIdType()) {
    case IMDB:/*from w w  w  .  ja  v  a2 s .  c om*/
        break;
    case TMDB:
        break;
    default:
        throw new UnsupportedOperationException(
                media.getMediaId().getIdType() + " is not supported by " + getName() + " image scrapper");
    }

    URL searchUrl = new URL("http", host, "/" + getTypeName() + "/" + apikey + "/" + media.getMediaId() + "/");// Last slash is required

    JSONObject json = URIRequest.getJsonDocument(searchUrl.toURI());
    JSONObject jmedia = JSONUtils.selectFirstObject(json);

    List<ImageInfo> imagesInfos = new ArrayList<ImageInfo>();
    if (jmedia == null) {
        return imagesInfos;
    }

    for (String tag : getTags()) {
        List<JSONObject> images = JSONUtils.selectList(tag, jmedia);
        if (images == null) {
            continue;
        }

        for (JSONObject image : images) {
            Map<ImageInfo.ImageProperty, String> imageFields = new EnumMap<ImageInfo.ImageProperty, String>(
                    ImageInfo.ImageProperty.class);
            int id = JSONUtils.selectInteger("id", image);
            imageFields.put(ImageInfo.ImageProperty.url, JSONUtils.selectString("url", image));
            imageFields.put(ImageInfo.ImageProperty.language, JSONUtils.selectString("lang", image));
            ImageInfo.ImageCategoryProperty category = getCategory(tag);
            imagesInfos.add(new ImageInfo(id, imageFields, category));
        }
    }

    return imagesInfos;
}

From source file:it.geosolutions.geobatch.unredd.script.util.FlowUtil.java

/**
 * Put some required tokens in the props map.<br/>
 * If orig map is null, it will be instantiated.<br/>
 * Null values will not be put into the map.
 * /*ww w. j a  va  2s  .  co m*/
 * @return
 */
public static Map<Statistics.Tokens, String> fillTokens(String rasterFullPath, String layerName, String year,
        String month, Map<Statistics.Tokens, String> props) {

    if (props == null) {
        props = new EnumMap(Statistics.Tokens.class);
    }

    if (rasterFullPath != null)
        props.put(Tokens.FILEPATH, rasterFullPath);
    if (layerName != null)
        props.put(Tokens.LAYERNAME, layerName);
    if (year != null)
        props.put(Tokens.YEAR, year);
    if (month != null)
        props.put(Tokens.MONTH, month);

    return props;
}

From source file:alfio.util.TemplateManager.java

@Autowired
public TemplateManager(JMustacheTemplateLoader templateLoader, MessageSource messageSource,
        UploadedResourceManager uploadedResourceManager) {
    this.messageSource = messageSource;
    this.uploadedResourceManager = uploadedResourceManager;
    Formatter dateFormatter = (o) -> {
        return (o instanceof ZonedDateTime) ? DateTimeFormatter.ISO_ZONED_DATE_TIME.format((ZonedDateTime) o)
                : String.valueOf(o);
    };//from w w  w.  j  a v a  2s . c  om
    this.compilers = new EnumMap<>(TemplateOutput.class);
    this.compilers.put(TemplateOutput.TEXT, Mustache.compiler().escapeHTML(false).standardsMode(false)
            .defaultValue("").nullValue("").withFormatter(dateFormatter).withLoader(templateLoader));
    this.compilers.put(TemplateOutput.HTML, Mustache.compiler().escapeHTML(true).standardsMode(false)
            .defaultValue("").nullValue("").withFormatter(dateFormatter).withLoader(templateLoader));
}

From source file:fr.ritaly.dungeonmaster.item.ItemManager.java

@Override
public synchronized void addItem(Item item, Sector sector) {
    Validate.notNull(item, "The given item is null");
    Validate.notNull(sector, "The given sector is null");

    if (items == null) {
        items = new EnumMap<Sector, Stack<Item>>(Sector.class);
    }/*  w w  w.  j a  va 2  s.  c  om*/

    Stack<Item> stack = items.get(sector);

    if (stack == null) {
        items.put(sector, stack = new Stack<Item>());
    }

    stack.push(item);

    fireItemAddedEvent(item, sector);
}

From source file:net.firejack.platform.api.registry.RegistryServiceTest.java

public static EnumMap<Elements, Lookup> createStandardTree() {
    EnumMap<Elements, Lookup> map = new EnumMap<Elements, Lookup>(Elements.class);

    RootDomain rootDomain = new RootDomain();
    rootDomain.setName("root123test.ru");

    ServiceResponse<RegistryNodeTree> response = OPFEngine.RegistryService.createRootDomain(rootDomain);
    logger.info(response.getMessage());/*from w  w  w .  j a  v a 2s . c  o  m*/
    Assert.assertNotNull("Can't be create root domain response null.", response);
    Assert.assertNotNull("Can't be create root domain item null.", response.getItem());

    rootDomain.setId(response.getItem().getId());
    map.put(Elements.ROOT_DOMAIN, rootDomain);

    Package aPackage = new Package();
    aPackage.setName("ext");
    aPackage.setUrlPath("/ext");
    aPackage.setParentId(rootDomain.getId());

    response = OPFEngine.RegistryService.createPackage(aPackage);
    logger.info(response.getMessage());
    Assert.assertNotNull("Can't be create package response null.", response);
    Assert.assertNotNull("Can't be create package item null.", response.getItem());
    aPackage.setId(response.getItem().getId());
    map.put(Elements.PACKAGE, aPackage);

    Domain domain = new Domain();
    domain.setName("extdomain");
    domain.setParentId(aPackage.getId());

    response = OPFEngine.RegistryService.createDomain(domain);
    logger.info(response.getMessage());
    Assert.assertNotNull("Can't be create domain response null.", response);
    Assert.assertNotNull("Can't be create domain item null.", response.getItem());
    domain.setId(response.getItem().getId());
    map.put(Elements.DOMAIN, domain);

    Entity entity = new Entity();
    entity.setName("Entity");
    entity.setStatus(RegistryNodeStatus.UNKNOWN);
    entity.setTypeEntity(EntityType.STANDARD.getEntityType());
    entity.setParentId(domain.getId());

    response = OPFEngine.RegistryService.createEntity(entity);
    logger.info(response.getMessage());
    Assert.assertNotNull("Can't be create entity response null.", response);
    Assert.assertNotNull("Can't be create entity item null.", response.getItem());
    entity.setId(response.getItem().getId());
    map.put(Elements.ENTITY, entity);

    Action action = new Action();
    action.setName("action");
    action.setParentId(entity.getId());
    action.setSoapMethod("readAction");
    action.setStatus(RegistryNodeStatus.UNKNOWN);
    action.setSoapUrlPath("/action");
    action.setMethod(HTTPMethod.GET);
    action.setProtocol(EntityProtocol.SOAP);
    action.setOutputVOEntity(entity);

    response = OPFEngine.RegistryService.createAction(action);
    logger.info(response.getMessage());
    Assert.assertNotNull("Can't be create action response null.", response);
    Assert.assertNotNull("Can't be create action item null.", response.getItem());
    action.setId(response.getItem().getId());
    map.put(Elements.ACTION, action);

    System system = new System();
    system.setParentId(rootDomain.getId());
    system.setName("system");
    system.setServerName("localhost");
    system.setStatus(RegistryNodeStatus.UNKNOWN);
    system.setPort(8080);

    response = OPFEngine.RegistryService.createSystem(system);
    logger.info(response.getMessage());
    Assert.assertNotNull("Can't be create system response null.", response);
    Assert.assertNotNull("Can't be create system item null.", response.getItem());
    system.setId(response.getItem().getId());
    map.put(Elements.SYSTEM, system);

    ServiceResponse response1 = OPFEngine.RegistryService.associatePackage(system.getId(), aPackage.getId());
    logger.info(response.getMessage());
    Assert.assertNotNull("Can't be Association Package response null.", response1);

    return map;
}

From source file:com.moviejukebox.model.artwork.Artwork.java

/**
 * Create a blank Artwork object//  w ww  . jav  a2  s. c o  m
 */
public Artwork() {
    this.sourceSite = Movie.UNKNOWN;
    this.type = null;
    this.url = Movie.UNKNOWN;
    this.sizes = new EnumMap<>(ArtworkSize.class);
}