List of usage examples for java.util EnumSet of
public static <E extends Enum<E>> EnumSet<E> of(E e1, E e2, E e3, E e4)
From source file:Numbers.java
public static void main(String[] args) { // create a set EnumSet<Numbers> set;// w w w . j a v a 2 s .c o m // add elements set = EnumSet.of(Numbers.FIVE, Numbers.FOUR, Numbers.THREE, Numbers.TWO); System.out.println(set); }
From source file:com.test.config.BackendConsoleWebConfig.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext webCtx = new AnnotationConfigWebApplicationContext(); webCtx.register(BackendConsoleMVCConfig.class); webCtx.register(BackendConsoleConfig.class); servletContext.addListener(new ContextLoaderListener(webCtx)); /* Spring Delegating Dispatcher Servlet */ Servlet dispatcherServlet = new DispatcherServlet(webCtx); ServletRegistration.Dynamic dispatcherServletReg = servletContext.addServlet("dispatcherServlet", dispatcherServlet);//from w w w. ja v a 2 s. c om dispatcherServletReg.setLoadOnStartup(1); dispatcherServletReg.setInitParameter("contextConfigLocation", ""); dispatcherServletReg.addMapping("/"); /* Spring Security Delegating Filter */ FilterRegistration springSecurityFilterChainReg = servletContext.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class); springSecurityFilterChainReg.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ERROR, DispatcherType.ASYNC), false, dispatcherServletReg.getName()); }
From source file:ws.wamp.jawampa.WampClientBuilder.java
/** * Construct a new WampClientBuilder object. *//* www . j ava 2 s . c o m*/ public WampClientBuilder() { // Add the default roles roles = EnumSet.of(WampRoles.Caller, WampRoles.Callee, WampRoles.Publisher, WampRoles.Subscriber); WampSerialization.addDefaultSerializations(serializations); }
From source file:eu.ggnet.dwoss.customer.priv.ConverterUtil.java
/** * Merges the old customer to a supplied new customer instance. * The new customer has all information of the old customer set to the first contact. * A Company may be added if the old.firma is not blank. * This Method also assumes, that there is exactly one Mandator used in creation with its defaults. * <p>// ww w.j av a 2 s. c om * @param old old customer * @param customer * @param mandatorMatchCode the mandatorMatchCode * @param defaults the defaults as filter for specific mandator data. * @return new customer. */ public static Customer mergeFromOld(OldCustomer old, Customer customer, String mandatorMatchCode, DefaultCustomerSalesdata defaults) { customer.setComment(old.getAnmerkung()); customer.clearFlags(); for (CustomerFlag customerFlag : old.getFlags()) { customer.add(customerFlag); } if (customer.getContacts().isEmpty()) customer.add(new Contact()); Contact contact = customer.getContacts().get(0); contact.setFirstName(old.getVorname() == null ? "" : old.getVorname()); contact.setLastName(old.getNachname() == null ? "" : old.getNachname()); if (old.getTitel() != null) { switch (old.getTitel()) { case "Herr": contact.setSex(MALE); break; case "Frau": contact.setSex(FEMALE); break; default: } } contact.setPrefered(true); if (!StringUtils.isBlank(old.getFirma()) || !customer.getCompanies().isEmpty()) { if (customer.getCompanies().isEmpty()) customer.add(new Company()); Company company = customer.getCompanies().get(0); company.setName(old.getFirma()); company.setLedger(old.getLedger()); company.setTaxId(old.getTaxId()); company.setPrefered(true); } for (Type t : EnumSet.of(EMAIL, FAX, PHONE, MOBILE)) { if (!StringUtils.isBlank(get(old, t)) || contact.prefered(t) != null) { if (contact.prefered(t) == null) contact.add(new Communication(t, true)); contact.prefered(t).setIdentifier(get(old, t)); } } if (!StringUtils.isBlank(old.getREAdresse()) || contact.prefered(INVOICE) != null) { if (contact.prefered(INVOICE) == null) contact.add(new Address(INVOICE)); Address rad = contact.prefered(INVOICE); rad.setStreet(old.getREAdresse()); rad.setCity(old.getREOrt() == null ? "" : old.getREOrt()); rad.setZipCode(old.getREPlz() == null ? "" : old.getREPlz()); } if (!StringUtils.isBlank(old.getLIAdresse()) || contact.prefered(SHIPPING) != null) { if (contact.prefered(SHIPPING) == null) contact.add(new Address(SHIPPING)); Address sad = contact.prefered(SHIPPING); sad.setStreet(old.getLIAdresse()); sad.setCity(old.getLIOrt() == null ? "" : old.getLIOrt()); sad.setZipCode(old.getLIPlz() == null ? "" : old.getLIPlz()); } MandatorMetadata m = customer.getMandatorMetadata(mandatorMatchCode); if (m == null) m = new MandatorMetadata(); m.setMandatorMatchcode(mandatorMatchCode); m.clearSalesChannels(); if (!old.getAllowedSalesChannels().equals(defaults.getAllowedSalesChannels())) { for (SalesChannel salesChannel : old.getAllowedSalesChannels()) { m.add(salesChannel); } } if (old.getPaymentCondition() == defaults.getPaymentCondition()) m.setPaymentCondition(null); else m.setPaymentCondition(old.getPaymentCondition()); if (old.getPaymentMethod() == defaults.getPaymentMethod()) m.setPaymentMethod(null); else m.setPaymentMethod(old.getPaymentMethod()); if (old.getShippingCondition() == defaults.getShippingCondition()) m.setShippingCondition(null); else m.setShippingCondition(old.getShippingCondition()); if (customer.getMandatorMetadata(mandatorMatchCode) == null && m.isSet()) customer.add(m); return customer; }
From source file:SearchApiExample.java
/** * Process command line options and call the service. *///w w w. j av a 2 s.com private static void processCommandLine(CommandLine line, Options options) { if (line.hasOption(HELP_OPTION)) { printHelp(options); } else if (line.hasOption(CONSUMER_KEY_OPTION) && line.hasOption(CONSUMER_SECRET_OPTION) && line.hasOption(ACCESS_TOKEN_OPTION) && line.hasOption(ACCESS_TOKEN_SECRET_OPTION)) { final String consumerKeyValue = line.getOptionValue(CONSUMER_KEY_OPTION); final String consumerSecretValue = line.getOptionValue(CONSUMER_SECRET_OPTION); final String accessTokenValue = line.getOptionValue(ACCESS_TOKEN_OPTION); final String tokenSecretValue = line.getOptionValue(ACCESS_TOKEN_SECRET_OPTION); final LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(consumerKeyValue, consumerSecretValue); final LinkedInApiClient client = factory.createLinkedInApiClient(accessTokenValue, tokenSecretValue); Map<SearchParameter, String> searchParameters = getSearchParameters(line); if (!searchParameters.isEmpty()) { System.out.println("Searching for users."); List<Parameter<FacetType, String>> facets = new ArrayList<Parameter<FacetType, String>>(); facets.add(new Parameter<FacetType, String>(FacetType.NETWORK, RelationshipCodes.OUT_OF_NETWORK_CONNECTIONS)); facets.add(new Parameter<FacetType, String>(FacetType.NETWORK, RelationshipCodes.SECOND_DEGREE_CONNECTIONS)); facets.add(new Parameter<FacetType, String>(FacetType.LANGUAGE, LanguageCodes.ENGLISH)); PeopleSearch people = client.searchPeople(searchParameters, EnumSet.of(ProfileField.FIRST_NAME, ProfileField.LAST_NAME, ProfileField.ID, ProfileField.HEADLINE), EnumSet.of(FacetField.NAME, FacetField.CODE, FacetField.BUCKET_NAME, FacetField.BUCKET_CODE, FacetField.BUCKET_COUNT), facets); printResult(people.getPeople()); printResult(people.getFacets()); } else { System.out.println("Searching for users."); People people = client.searchPeople(); printResult(people); } } else { printHelp(options); } }
From source file:org.ambraproject.article.service.FetchArticleServiceImpl.java
/** * * @param article- the Article content/*from w w w . j a va 2 s. c om*/ * @return Article DOM document * @throws java.io.IOException * @throws NoSuchArticleIdException * @throws javax.xml.parsers.ParserConfigurationException * @throws org.xml.sax.SAXException * @throws org.ambraproject.ApplicationException */ private Document getAnnotatedContentAsDocument(final ArticleInfo article) throws IOException, NoSuchArticleIdException, ParserConfigurationException, SAXException, ApplicationException { DataSource content; try { content = getArticleXML(article.getDoi()); } catch (NoSuchArticleIdException ex) { throw new NoSuchArticleIdException(article.getDoi(), "(representation=" + articleTransformService.getArticleRep() + ")", ex); } final AnnotationView[] annotations = annotationService.listAnnotationsNoReplies(article.getId(), EnumSet.of(AnnotationType.MINOR_CORRECTION, AnnotationType.FORMAL_CORRECTION, AnnotationType.RETRACTION, AnnotationType.NOTE), AnnotationService.AnnotationOrder.OLDEST_TO_NEWEST); return applyAnnotationsOnContentAsDocument(content, annotations); }
From source file:com.opengamma.financial.analytics.volatility.surface.EquityOptionVolatilitySurfaceDataFunctionDeprecated.java
/** * // Computes active expiry dates, which fall on the Saturday following the 3rd Friday of an expiry month * @param valDate The evaluation date/* w w w.ja v a 2s .com*/ * @return The expiry dates */ public static TreeSet<LocalDate> getExpirySet(final LocalDate valDate) { final TemporalAdjuster thirdFriday = TemporalAdjusters.dayOfWeekInMonth(3, DayOfWeek.FRIDAY); TreeSet<LocalDate> expirySet = new TreeSet<LocalDate>(); // Add the next six months' Expiries although they are not guaranteed to be traded final LocalDate thisMonthsExpiry = valDate.with(thirdFriday).plusDays(1); if (thisMonthsExpiry.isAfter(valDate)) { expirySet.add(thisMonthsExpiry); } for (int m = 1; m <= 6; m++) { expirySet.add(valDate.plusMonths(m).with(thirdFriday).plusDays(1)); } // Add the Quarterly IMM months out 3 years final Set<Month> immQuarters = EnumSet.of(Month.MARCH, Month.JUNE, Month.SEPTEMBER, Month.DECEMBER); LocalDate nextQuarter = valDate; do { nextQuarter = nextQuarter.plusMonths(1); } while (!immQuarters.contains(nextQuarter.getMonth())); for (int q = 1; q <= 12; q++) { expirySet.add(nextQuarter.with(thirdFriday).plusDays(1)); nextQuarter = nextQuarter.plusMonths(3); } return expirySet; }