List of usage examples for com.google.common.base Preconditions checkNotNull
public static <T> T checkNotNull(T reference, @Nullable Object errorMessage)
From source file:co.cask.cdap.internal.app.workflow.WorkflowNodeCreator.java
static WorkflowNode createWorkflowActionNode(String programName, SchedulableProgramType programType) { switch (programType) { case MAPREDUCE: Preconditions.checkNotNull(programName, "MapReduce name is null."); Preconditions.checkArgument(!programName.isEmpty(), "MapReduce name is empty."); break;/*from w w w .ja v a 2s . co m*/ case SPARK: Preconditions.checkNotNull(programName, "Spark name is null."); Preconditions.checkArgument(!programName.isEmpty(), "Spark name is empty."); break; case CUSTOM_ACTION: //no-op break; default: break; } return new WorkflowActionNode(programName, new ScheduleProgramInfo(programType, programName)); }
From source file:com.google.security.zynamics.binnavi.disassembly.algorithms.CFunctionNodeColorizer.java
/** * Returns the proper color for function nodes of a given type. * /* w w w. j ava2 s .c o m*/ * @param type The type of the function. * * @return The color for function nodes of the given type. */ public static Color getFunctionColor(final FunctionType type) { Preconditions.checkNotNull(type, "IE02200: Type argument cannot be null"); switch (type) { case ADJUSTOR_THUNK: return ConfigManager.instance().getColorSettings().getAdjustorThunkFunctionColor(); case IMPORT: return ConfigManager.instance().getColorSettings().getImportedFunctionColor(); case LIBRARY: return ConfigManager.instance().getColorSettings().getLibraryFunctionColor(); case NORMAL: return ConfigManager.instance().getColorSettings().getNormalFunctionColor(); case THUNK: return ConfigManager.instance().getColorSettings().getThunkFunctionColor(); case UNKNOWN: return ConfigManager.instance().getColorSettings().getUnknownFunctionColor(); default: throw new IllegalStateException(String.format("IE00908: Unknown function type %s", type)); } }
From source file:com.github.jeluard.guayaba.util.concurrent.ThreadFactoryBuilders.java
/** * @param pattern// ww w. java 2 s . c o m * @param logger * @return {@link ThreadFactoryBuilder} producing daemon thread and relying on {@link UncaughtExceptionHandlers#defaultHandler(java.util.logging.Logger)} */ public static ThreadFactoryBuilder safeBuilder(final String pattern, final Logger logger) { Preconditions.checkNotNull(pattern, "null pattern"); Preconditions.checkNotNull(logger, "null logger"); return new ThreadFactoryBuilder().setDaemon(true) .setUncaughtExceptionHandler(UncaughtExceptionHandlers.defaultHandler(logger)) .setNameFormat(pattern); }
From source file:org.jclouds.orion.domain.BlobType.java
public static BlobType fromValue(String type) { try {/*from w ww .j ava 2 s. co m*/ return BlobType.valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, Preconditions.checkNotNull(type, "type"))); } catch (IllegalArgumentException e) { return UNRECOGNIZED; } }
From source file:com.appmogli.gdriveexplorer.ClientCredentials.java
public static void errorIfNotSpecified() { Preconditions.checkNotNull(KEY, "Please enter your API key from https://code.google.com/apis/console/?api=drive in " + ClientCredentials.class); }
From source file:fr.norad.visuwall.plugin.jenkins.States.java
public static final BuildState asVisuwallState(String jenkinsState) { Preconditions.checkNotNull(jenkinsState, "jenkinsState is mandatory"); jenkinsState = jenkinsState.toLowerCase(); BuildState state = STATE_MAPPING.get(jenkinsState); if (state == null) { state = BuildState.UNKNOWN; LOG.warn(jenkinsState + " is not available in Jenkins plugin. Please report it to Visuwall dev team."); }//from w ww .j av a 2 s. c o m return state; }
From source file:io.pravega.common.function.Callbacks.java
/** * Invokes the given Consumer with the given argument, and catches any exceptions that it may throw. * * @param consumer The consumer to invoke. * @param argument The argument to pass to the consumer. * @param failureHandler An optional callback to invoke if the consumer threw any exceptions. * @param <T> The type of the argument. * @throws NullPointerException If the consumer is null. */// ww w. java 2 s .c o m public static <T> void invokeSafely(Consumer<T> consumer, T argument, Consumer<Throwable> failureHandler) { Preconditions.checkNotNull(consumer, "consumer"); try { consumer.accept(argument); } catch (Exception ex) { if (failureHandler != null) { invokeSafely(failureHandler, ex, null); } } }
From source file:org.apache.drill.exec.coord.zk.PathUtils.java
/** * Returns a normalized, combined path out of the given path segments. * * @param parts path segments to combine * @see #normalize(String)// w w w.jav a 2 s . c o m */ public static final String join(final String... parts) { final StringBuilder sb = new StringBuilder(); for (final String part : parts) { Preconditions.checkNotNull(part, "parts cannot contain null"); if (!Strings.isNullOrEmpty(part)) { sb.append(part).append("/"); } } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } final String path = sb.toString(); return normalize(path); }
From source file:com.google.security.zynamics.binnavi.ZyGraph.Builders.ZyGroupNodeBuilder.java
/** * Builds the content of a single group node. * * @param node The group node that provides the underlying data. * * @return The created content./*from ww w.ja va 2 s . co m*/ */ public static ZyLabelContent buildContent(final INaviGroupNode node) { Preconditions.checkNotNull(node, "IE01558: Node argument can not be null"); final ZyLabelContent content = new ZyLabelContent(null); buildContent(content, node); return content; }
From source file:com.epam.ta.reportportal.commons.EntityUtils.java
/** * Normalize any ID for database ID fields, for example * * @param id ID to normalize// w w w . j a v a 2 s . c o m * @return String */ public static String normalizeId(String id) { return Preconditions.checkNotNull(id, "Provided value shouldn't be null").toLowerCase(); }