public void whenCheckArgumentEvaluatesFalse_throwsException() {
    int age = -18;
  
    assertThatThrownBy(() -> Preconditions.checkArgument(age > 0))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage(null).hasNoCause();
}

        

public double sqrt(double input) throws IllegalArgumentException {
      Preconditions.checkArgument(input > 0.0,
         "Illegal Argument passed: Negative value %s.", input);
      return Math.sqrt(input);
   }

        

public void testDivisorNotZero(final int divisor)
{
	   Preconditions.checkArgument(divisor != 0, "Zero divisor not allowed.");
}

        

public void testCheckArgument_complexMessage_failure() {
	try {
		Preconditions.checkArgument(false, FORMAT, 5);
		fail("no exception thrown");
	} catch (IllegalArgumentException expected) {
		verifyComplexMessage(expected);
	}
}

        

public static double sqrt(double value) { 
    Preconditions.checkArgument(value >= 0.0, "negative value: %s", value); 
    // calculate the square root 
}

        

public <T> Class<? extends T> getClass(String path, Class<T> iface, Class<? extends T> defaultImpl) {
  if (this.hasPath(path)) {
    String className = this.getString(path);
    ;
    try {
      Class<?> clazz = Class.forName(className);
      Preconditions.checkArgument(iface.isAssignableFrom(clazz));
      return (Class<? extends T>) clazz;
    } catch (ClassNotFoundException e) {
      throw UserException.unsupportedError(e)
      .message("Failure while attempting to find implementation class %s for interface  %s. The sabot config key is %s ",
          defaultImpl.getName(), iface.getName(), path).build(logger);
    }
  }

  return defaultImpl;
}

        

public Conversation getCurrentConversationByChannelId(Client client, String channelId, Supplier<Conversation> supplier) {
    Preconditions.checkNotNull(client);
    Preconditions.checkArgument(StringUtils.isNoneBlank(channelId));
    final ObjectId conversationId = storeService.mapChannelToCurrentConversationId(channelId);
    if (conversationId != null) {
        Conversation conversation = storeService.get(conversationId);
        if(Objects.equal(conversation.getOwner(), client.getId())){
            return getConversation(client, conversationId);
        } else {
            //this should never happen unless we have two clients with the same channelId
            throw new IllegalStateException("Conversation for channel '" + channelId + "' has a different owner "
                    + "as the current client (owner: " + conversation.getOwner() + ", client: " + client + ")!");
        }
    } else {
        final Conversation c = supplier.get();
        if(c != null){
            c.setId(null);
            c.setOwner(client.getId());
            c.setChannelId(channelId);
            return storeService.store(c);
        } else {
            return null;
        }
    }
}

        

private void mergeChildrenWithMultipleDeclarations(
        XmlElement lowerPriorityChild,
        MergingReport.Builder mergingReport) {

    Preconditions.checkArgument(lowerPriorityChild.getType().areMultipleDeclarationAllowed());
    if (lowerPriorityChild.getType().areMultipleDeclarationAllowed()) {
        for (XmlElement sameTypeChild : getAllNodesByType(lowerPriorityChild.getType())) {
            if (sameTypeChild.getId().equals(lowerPriorityChild.getId()) &&
                    sameTypeChild.isEquals(lowerPriorityChild)) {
                return;
            }
        }
    }
    // if we end up here, we never found a child of this element with the same key and strictly
    // equals to the lowerPriorityChild so we should merge it in.
    addElement(lowerPriorityChild, mergingReport);
}

        

public TopConf(Configuration conf) {
  isEnabled = conf.getBoolean(DFSConfigKeys.NNTOP_ENABLED_KEY,
      DFSConfigKeys.NNTOP_ENABLED_DEFAULT);
  String[] periodsStr = conf.getTrimmedStrings(
      DFSConfigKeys.NNTOP_WINDOWS_MINUTES_KEY,
      DFSConfigKeys.NNTOP_WINDOWS_MINUTES_DEFAULT);
  nntopReportingPeriodsMs = new int[periodsStr.length];
  for (int i = 0; i < periodsStr.length; i++) {
    nntopReportingPeriodsMs[i] = Ints.checkedCast(
        TimeUnit.MINUTES.toMillis(Integer.parseInt(periodsStr[i])));
  }
  for (int aPeriodMs: nntopReportingPeriodsMs) {
    Preconditions.checkArgument(aPeriodMs >= TimeUnit.MINUTES.toMillis(1),
        "minimum reporting period is 1 min!");
  }
}

        

public static void validatePMMLVsSchema(PMML pmml, InputSchema schema) {
  List<Model> models = pmml.getModels();
  Preconditions.checkArgument(models.size() == 1,
      "Should have exactly one model, but had %s", models.size());

  Model model = models.get(0);
  Preconditions.checkArgument(model instanceof ClusteringModel);
  Preconditions.checkArgument(model.getMiningFunction() == MiningFunction.CLUSTERING);

  DataDictionary dictionary = pmml.getDataDictionary();
  Preconditions.checkArgument(
      schema.getFeatureNames().equals(AppPMMLUtils.getFeatureNames(dictionary)),
      "Feature names in schema don't match names in PMML");

  MiningSchema miningSchema = model.getMiningSchema();
  Preconditions.checkArgument(schema.getFeatureNames().equals(
      AppPMMLUtils.getFeatureNames(miningSchema)));

}        
main