List of usage examples for java.util EnumSet allOf
public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType)
From source file:Main.java
@SuppressWarnings("unchecked") public static List<Object> loadEnums(List<String> classFullNameList) { Class aeClass = null;//from w w w . jav a 2 s. c om List<Object> retList = new ArrayList<Object>(); for (String aeString : classFullNameList) { try { aeClass = Class.forName(aeString); } catch (ClassNotFoundException e) { e.printStackTrace(); } for (Object ae : EnumSet.allOf(aeClass)) { retList.add(ae); } } return retList; }
From source file:com.moviejukebox.model.enumerations.TitleSortType.java
/** * Convert a string into an Enum type// w w w . ja v a 2 s. c om * * @param titleSortTypeString * @return TitleSortType */ public static TitleSortType fromString(String titleSortTypeString) { if (StringUtils.isNotBlank(titleSortTypeString)) { for (final TitleSortType titleSortType : EnumSet.allOf(TitleSortType.class)) { if (titleSortTypeString.equalsIgnoreCase(titleSortType.toString().toLowerCase())) { return titleSortType; } } } // We've not found the type, so use the default return TitleSortType.TITLE; }
From source file:se.vgregion.webbisar.types.Hospital.java
public static Hospital fromLongString(String str) throws ParseException { if (isEmpty(str)) { throw new ParseException("String empty or null in Hospital enum!", 0); }/* www .j a v a 2 s . c om*/ for (Hospital h : EnumSet.allOf(Hospital.class)) { if (h.getLongName().equals(str)) { return h; } } throw new ParseException(str + " not in range in Hospital enum!", 0); }
From source file:com.moviejukebox.model.enumerations.VideoType.java
/** * Convert a string into an Enum type//from w ww . j av a2 s. c om * * @param sType * @return */ public static VideoType fromString(String sType) { if (StringUtils.isNotBlank(sType)) { for (final VideoType extension : EnumSet.allOf(VideoType.class)) { if (sType.equalsIgnoreCase(extension.type)) { return extension; } } } // We've not found the type, so return both return ALL; }
From source file:cn.org.once.cstack.model.DeploymentType.java
public static DeploymentType from(String name) { return EnumSet.allOf(DeploymentType.class).stream() .filter(t -> FilenameUtils.getExtension(name).equalsIgnoreCase(t.extension)).findFirst() .orElse(DeploymentType.JAR); }
From source file:com.moviejukebox.model.enumerations.WatchedWithExtension.java
/** * Convert a string into an Enum type//from w w w . j a v a 2 s.c o m * * @param extensionString * @return */ public static WatchedWithExtension fromString(String extensionString) { if (StringUtils.isNotBlank(extensionString)) { for (final WatchedWithExtension extension : EnumSet.allOf(WatchedWithExtension.class)) { if (extensionString.equalsIgnoreCase(extension.type)) { return extension; } } } // We've not found the type, so return both return BOTH; }
From source file:com.moviejukebox.model.enumerations.WatchedWithLocation.java
/** * Convert a string into an Enum type/*from ww w .j a va 2s. c o m*/ * * @param location * @return * @throws IllegalArgumentException If type is not recognised * */ public static WatchedWithLocation fromString(String location) { if (StringUtils.isNotBlank(location)) { for (final WatchedWithLocation withLocation : EnumSet.allOf(WatchedWithLocation.class)) { if (location.equalsIgnoreCase(withLocation.toString())) { return withLocation; } } } // We've not found the type, so reutrn CUSTOM return CUSTOM; }
From source file:com.richtodd.android.quiltdesign.app.MainPreferenceActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); getFragmentManager().beginTransaction().replace(android.R.id.content, CommonPreferenceFragment.create(EnumSet.allOf(PreferenceSections.class))).commit(); }
From source file:com.cisco.oss.foundation.http.server.jetty.HttpServerUtil.java
public static void addFiltersToServletContextHandler(String serviceName, HttpThreadPool threadPool, ServletContextHandler context) { context.addFilter(new FilterHolder(new FlowContextFilter(serviceName)), "/*", EnumSet.allOf(DispatcherType.class)); context.addFilter(new FilterHolder(new ErrorHandlingFilter(serviceName)), "/*", EnumSet.allOf(DispatcherType.class)); context.addFilter(new FilterHolder(new MonitoringFilter(serviceName, threadPool)), "/*", EnumSet.allOf(DispatcherType.class)); // addMonitoringFilter(serviceName, threadPool, context); context.addFilter(new FilterHolder(new HttpMethodFilter(serviceName)), "/*", EnumSet.allOf(DispatcherType.class)); context.addFilter(new FilterHolder(new RequestValidityFilter(serviceName)), "/*", EnumSet.allOf(DispatcherType.class)); context.addFilter(new FilterHolder(new AvailabilityFilter(serviceName, threadPool)), "/*", EnumSet.allOf(DispatcherType.class)); context.addFilter(new FilterHolder(new TraceFilter(serviceName)), "/*", EnumSet.allOf(DispatcherType.class)); if (ConfigurationFactory.getConfiguration().getBoolean(serviceName + ".http.pingFilter.isEnabled", true)) { context.addFilter(new FilterHolder(new PingFilter(serviceName)), "/*", EnumSet.allOf(DispatcherType.class)); } else {/*from w w w. j a v a 2s . c om*/ context.addServlet(new ServletHolder(new PingServlet(serviceName)), "/probe"); } context.addFilter(new FilterHolder(new CrossOriginFilter(serviceName)), "/*", EnumSet.allOf(DispatcherType.class)); }
From source file:com.omertron.themoviedbapi.tools.MethodBase.java
/** * Convert a string into an Enum type//from w ww . j av a 2s .c o m * * @param value * @return */ public static MethodBase fromString(String value) { if (StringUtils.isNotBlank(value)) { for (final MethodBase method : EnumSet.allOf(MethodBase.class)) { if (value.equalsIgnoreCase(method.value)) { return method; } } } // We've not found the type! throw new IllegalArgumentException("Method '" + value + "' not recognised"); }