List of usage examples for org.apache.commons.lang3 EnumUtils isValidEnum
public static <E extends Enum<E>> boolean isValidEnum(final Class<E> enumClass, final String enumName)
Checks if the specified name is a valid enum for the class.
This method differs from Enum#valueOf in that checks if the name is a valid enum without needing to catch the exception.
From source file:com.cloudera.impala.catalog.TestLoadHdfsMetadataPerf.java
public static void main(String[] args) { if (args.length != 3) { LOG.error("Please enter MethodName Dirpath TotalPartitionNum."); return;//from w ww. j av a 2s . co m } else if (!EnumUtils.isValidEnum(MethodName.class, args[0])) { LOG.error("Please enter a valid MethodName."); return; } else if (!args[2].matches("\\d+")) { LOG.error("Please enter a positive interger as TotalPartitioNum."); return; } MethodName methodName = MethodName.valueOf(args[0]); String dirPath = args[1]; int totalPartitionNum = Integer.parseInt(args[2]); String msg = "List file status for dirPath:" + dirPath + "with totalPartitionNum:" + totalPartitionNum + " via " + methodName.name(); TestLoadHdfsMetadataPerf.beforeClass(); try { LOG.info("Start to " + msg); testMethod(methodName, dirPath, totalPartitionNum); } catch (Exception e) { LOG.error("Failed to " + msg, e); } finally { TestLoadHdfsMetadataPerf.afterClass(); } }
From source file:io.thekraken.grok.configuration.model.InputType.java
public static boolean isValid(String value) { return EnumUtils.isValidEnum(InputType.class, value.toUpperCase()); }
From source file:com.nortal.petit.core.util.SqlSearchUtil.java
public static String formatSearchPattern(String pattern, String searchType) { if (!EnumUtils.isValidEnum(SearchType.class, searchType)) { throw new IllegalArgumentException("Unsupported search type: " + searchType); }/*from w ww . j a va 2 s. co m*/ return formatSearchPattern(pattern, SearchType.valueOf(searchType)); }
From source file:de.mpg.imeji.presentation.license.LicenseViewer.java
/** * Return a license according to its name. The license must be an {@link ImejiLicenses} * * @param name// w w w.ja va2 s . c om * @return */ public License getLicense(String name) { if (EnumUtils.isValidEnum(ImejiLicenses.class, name)) { return new License(ImejiLicenses.valueOf(name)); } return null; }
From source file:de.mpg.imeji.presentation.license.LicenseEditor.java
/** * Constructor//from www .j a v a2 s.c o m * * @throws ImejiException */ public LicenseEditor(Locale locale, Item item) { final License active = LicenseUtil.getActiveLicense(item); this.licenseMenu = new ArrayList<>(); this.showInput = !(active == null || EnumUtils.isValidEnum(ImejiLicenses.class, active.getName())); if (!showInput) { this.licenseName = active == null ? Imeji.RESOURCE_BUNDLE.getLabel(NO_LICENSE, locale) : active.getName(); } else { this.customLicenseName = active.getName(); this.customLicenseUrl = active.getUrl(); } if (item.getStatus().equals(Status.PENDING)) { licenseMenu.add(new SelectItem(Imeji.RESOURCE_BUNDLE.getLabel(NO_LICENSE, locale))); } for (final ImejiLicenses lic : ImejiLicenses.values()) { licenseMenu.add(new SelectItem(lic.name(), lic.getLabel())); } init(item); }
From source file:eionet.webq.dto.Conversion.java
public boolean isBasic() { return EnumUtils.isValidEnum(BASIC_TYPES.class, this.resultType); }
From source file:io.unravelling.ferguson.configuration.FergusonConfiguration.java
/** * Validates the server type that was supplied. * @param configuration Configuration of the server. * @return Boolean indicating if the server configuration is correct or not. *//*from ww w . j av a 2 s . c om*/ static boolean validateServerType(final Properties configuration) { return (configuration.containsKey(FergusonConfiguration.SERVER_TYPE) && EnumUtils .isValidEnum(ServerType.class, configuration.getProperty(FergusonConfiguration.SERVER_TYPE))); }
From source file:io.apiman.gateway.engine.vertx.polling.fetchers.HttpResourceFetcher.java
public HttpResourceFetcher(Vertx vertx, URI uri, Map<String, String> config, boolean isHttps) { this.vertx = vertx; this.uri = uri; this.isHttps = isHttps; this.config = config; String authString = config.getOrDefault("auth", "NONE").toUpperCase(); Arguments.require(EnumUtils.isValidEnum(AuthType.class, authString), "auth must be one of: " + AuthType.all()); authenticator = AuthType.valueOf(authString).getAuthenticator(); authenticator.validateConfig(config); }
From source file:com.linkedin.pinot.common.data.DateTimeGranularitySpec.java
/** * Check correctness of granularity of {@link DateTimeFieldSpec} * @param granularity//from ww w .j a va 2s .c o m * @return */ public static boolean isValidGranularity(String granularity) { Preconditions.checkNotNull(granularity); String[] granularityTokens = granularity.split(COLON_SEPARATOR); Preconditions.checkArgument(granularityTokens.length == MAX_GRANULARITY_TOKENS, GRANULARITY_TOKENS_ERROR_STR); Preconditions.checkArgument(granularityTokens[GRANULARITY_SIZE_POSITION].matches(NUMBER_REGEX), GRANULARITY_PATTERN_ERROR_STR); Preconditions.checkArgument( EnumUtils.isValidEnum(TimeUnit.class, granularityTokens[GRANULARITY_UNIT_POSITION]), GRANULARITY_PATTERN_ERROR_STR); return true; }
From source file:com.linkedin.pinot.common.data.DateTimeFormatUnitSpec.java
public static boolean isValidUnitSpec(String unit) { if (EnumUtils.isValidEnum(TimeUnit.class, unit) || EnumUtils.isValidEnum(DateTimeTransformUnit.class, unit)) { return true; }//w ww. ja v a2 s.c o m return false; }